I have searched the forum and the web and couldn’t find an answer to this question. I apologize if it has been answered before.
I have an AppleScript Studio application that contains a window with some buttons in it. The buttons perform certain actions when clicked on. Now, I want them to perform a different action if they have been option-clicked. Is there a way to do this? I have tried reading Apple’s documentation and messing with key events and the like.
It’s actually pretty easy. The trick is that you can get the “option key down” as part of the event record of the “mouse down” event so attach that event to your button in IB as well as the clicked event. Then in your script, add some code like this:
property opt_down : false
on mouse down the_object event the_event
set opt_down to (option key down of the_event)
end mouse down
on clicked the_object
if the_object's name = "button" then
if opt_down = true then
display dialog "you clicked me with the Option key down"
else
display dialog "you clicked me without the Option key down"
end if
end if
end clicked
Hey, is there any way to add the corresponding key equivalent? As in, the keyboard equivalent for the button is command-L; it would be nice if the keyboard equivalent for option-clicking the button were command-option-L.