Answer the question
In order to leave comments, you need to log in
OS X app development, problem with global NSEvents
Good afternoon, colleagues.
Putting together the first application for OS X. Faced a problem.
It is necessary that the program in the background catches the global keystroke ctrl, alt, cmd (hold). Maybe someone came across?
Answer the question
In order to leave comments, you need to log in
Is it ?
There's an example for ctrl alt cmd + t
I'm posting the code that worked for my case.
I'm adding the global event handler after the app launches. My shortcut makes ctrl+alt+cmd+T open my app.
- (void) applicationWillFinishLaunching:(NSNotification *)aNotification
{
// Register global key handler, passing a block as a callback function
[NSEvent addGlobalMonitorForEventsMatchingMask:NSKeyDownMask
handler:^(NSEvent *event){
// Activate app when pressing cmd+ctrl+alt+T
if([event modifierFlags] == 1835305 && [[event charactersIgnoringModifiers] compare:@"t"] == 0) {
[NSApp activateIgnoringOtherApps:YES];
}
}];
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question