Hi,
I'm trying to use global keyboard shortcuts inside my Cocoa app and, as far as I know, this can only be done with Carbon.
I'm relatively new to Cocoa and Mac Programming as a whole (This being my first real application) and so, I'm EXTREMELY new to Carbon! From what I can understand Cocoa and Carbon are just two different APIs with Cocoa being the 'newer' one (OS X) and the 'preferred' one whereas Carbon is the 'older' (Pre OS X) but it still can do things Cocoa can't so it still gets used.
^^ I hope I understood it right, please correct me if I'm wrong!
Anyway, I have a Cocoa app and I'm trying to reference a Cocoa method in Carbon code. The keyboard shortcuts work and the Carbon code I have is
Like I said, that works. But I have two methods in my app controller (Cocoa) that I'd like to call instead of NSLog. they're called increaseBrightness and decreaseBrightness. I'd love to just be able to put [self increaseBrightness] instead of the NSLogs but I get errors. I've ready through the CarbonCocoa Integration Guide and it just seems really confusing! Any help?
Thanks,
Ash
I'm trying to use global keyboard shortcuts inside my Cocoa app and, as far as I know, this can only be done with Carbon.
I'm relatively new to Cocoa and Mac Programming as a whole (This being my first real application) and so, I'm EXTREMELY new to Carbon! From what I can understand Cocoa and Carbon are just two different APIs with Cocoa being the 'newer' one (OS X) and the 'preferred' one whereas Carbon is the 'older' (Pre OS X) but it still can do things Cocoa can't so it still gets used.
^^ I hope I understood it right, please correct me if I'm wrong!
Anyway, I have a Cocoa app and I'm trying to reference a Cocoa method in Carbon code. The keyboard shortcuts work and the Carbon code I have is
Code:
OSStatus MyHotKeyHandler(EventHandlerCallRef nextHandler,EventRef theEvent, void *userData) {
NSAutoreleasePool *localPool;
localPool = [[NSAutoreleasePool alloc] init];
EventHotKeyID hkCom;
GetEventParameter(theEvent,kEventParamDirectObject,typeEventHotKeyID,NULL,sizeof(hkCom),NULL,&hkCom);
int l = hkCom.id;
switch (l) {
case 1:
NSLog(@"Decrease shorcut!");
break;
case 2:
NSLog(@"Increase shortcut!");
break;
}
[localPool release];
return noErr;
}
Like I said, that works. But I have two methods in my app controller (Cocoa) that I'd like to call instead of NSLog. they're called increaseBrightness and decreaseBrightness. I'd love to just be able to put [self increaseBrightness] instead of the NSLogs but I get errors. I've ready through the CarbonCocoa Integration Guide and it just seems really confusing! Any help?
Thanks,
Ash