nukl
nukl

Reputation: 10511

KeyDown event and drag'n'drop

Can i capture keyDown event when user drops a file on application icon in the dock?

For example, if user drops on application icon some files, that's handle with "method_one". And if user drops on application icon some files and holding the option key, that's handle with "method_two".

And all "UI" in this application it's just a dock icon. No windows, panels etc. thanks

Upvotes: 0

Views: 237

Answers (1)

Jon Steinmetz
Jon Steinmetz

Reputation: 4124

One method you could use would be to poll the key state when your application starts up. NSEvent does not provide a way to do this without receiving an event first but you can use CGEvent. As discussed here, you can create a new event and poll its modifier keys. The code snippet looks like this:

CGEventRef event = CGEventCreate( NULL );
CGEventFlags mods = CGEventGetFlags( event );
if( mods & kCGEventFlagMaskShift )
    NSLog( @"Shift key is being pressed" );
CFRelease( event );

Upvotes: 1

Related Questions