How to check which toolbar button was clicked and then cancel the action

Look at this for question 1. I think this will answer that one.