Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- - (void) setupAppFrontSwitchedHandler
- {
- EventTypeSpec spec = { kEventClassApplication, kEventAppFrontSwitched };
- OSStatus err = InstallApplicationEventHandler(NewEventHandlerUPP(AppFrontSwitchedHandler), 1, &spec, (void*)self, NULL);
- if (err)
- NSLog(@"Could not install event handler");
- }
- - (void) appFrontSwitched {
- NSLog(@"%@", [[NSWorkspace sharedWorkspace] activeApplication]);
- }
- static OSStatus AppFrontSwitchedHandler(EventHandlerCallRef inHandlerCallRef, EventRef inEvent, void *inUserData)
- {
- [(id)inUserData appFrontSwitched];
- return 0;
- }
- // NSWorkspaceDidActivateApplicationNotification
- [[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self selector:@selector(foremostAppActivated:) name:NSWorkspaceDidActivateApplicationNotification object:nil];
Add Comment
Please, Sign In to add comment