vcirilli vcirilli - 1 year ago 71
Objective-C Question

How to check if Option key is down when user clicks a NSButton

I have a few checkboxes along with textfields on a NSPanel that opens to get user parameters.
As an option, I'd like the user to be able to set/unset all the checkboxes on the panel by holding the option key when they press any of the checkboxes.

I'm not sure where/how to check what the key board is doing when the user clicks the button.

Answer Source

check [NSEvent modifierFlags]...

if ([NSEvent modifierFlags ] & NSAlternateKeyMask)
    //do something
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download