Check for Option Key Pressed


#1

I have a very simple procedure that checks for the option key being pressed.


fileglobal mystate
if info(“modifiers”) contains "option"
mystate = "Yesterday"
else
mystate = "Today"
endif
Message mystate


It works correctly if I press the “Run” button in the procedure window, but it does not work if I call it from a menu. What am I missing?


#2

In my tests using your code I found similar results. Triggering the procedure from the Run tool in the procedure window while holding down the option key gave consistently correct results. Triggering the procedure from the Action menu while holding down the option key seemed to ignore the modifier altogether. I did notice that if you did this several times in a row that the option modifier would be recognized on a later triggering (sometimes even when the current triggering had no modifier pressed).

So, it is either a bug or modifiers are not supported in this way for the Action menu - possibly due to a conflict with Keyword Equivalents in their menu names.


#3

It looks like a bug. Using the one line procedure

Message info("modifiers")

if I hold the option key down and press the run button, the message is

option leftbutton

If I hold the option key, and call the procedure from the Action menu, the message is

leftbutton

It works correctly, when the procedure is called by clicking an object on a form.


#4

I was able to make a change to get this to work with modifier keys (shift, option, etc.), however, I could not get it to work with right button clicks, it always shows leftButton no matter what button is clicked. It appears that Apple’s code is not passing that information to the application. (Clicks in the menu bar are not handled by the application, Apple’s code handles them for the application.)