hotkey problem
hotkey problem
- Subject: hotkey problem
- From: Salánki Benjámin <email@hidden>
- Date: Tue, 21 Jan 2003 01:56:31 +0100
Hi, I have the following code, controller is in the header file defined
as IBOutlet id controller; which is an object. Now it must me my bad,
because I don't know a thing about Carbon, but I get an error saying
controller is undeclared. any ideas?
Thank,
Ben
#import "SFHotkeyController.h"
#import <Carbon/Carbon.h>
const UInt32 kLockUIElementHotKeyIdentifier = 'lUIk';
const UInt32 kLockUIElementHotKey = 109; //F10 will be the key
to hit, in combo with Cmd
//AppShell *gAppShell = NULL;
EventHotKeyRef gMyHotKeyRef;
EventHotKeyID gMyHotKeyID;
EventHandlerUPP gAppHotKeyFunction;
pascal OSStatus LockUIElementHotKeyHandler(EventHandlerCallRef
nextHandler,EventRef theEvent, void *userData);
@implementation SFHotkeyController
- (void)awakeFromNib
{
EventTypeSpec eventType;
gAppHotKeyFunction = NewEventHandlerUPP(LockUIElementHotKeyHandler);
eventType.eventClass = kEventClassKeyboard;
eventType.eventKind = kEventHotKeyPressed;
InstallApplicationEventHandler(gAppHotKeyFunction,1,&eventType,NULL,NULL
);
gMyHotKeyID.signature = kLockUIElementHotKeyIdentifier;
gMyHotKeyID.id = 1;
RegisterEventHotKey(kLockUIElementHotKey, cmdKey, gMyHotKeyID,
GetApplicationEventTarget(), 0, &gMyHotKeyRef);
}
pascal OSStatus LockUIElementHotKeyHandler(EventHandlerCallRef
nextHandler,EventRef theEvent, void *userData)
{
// We only register for one hotkey, so if we get here we know the
hotkey combo was pressed; we can do whatever we want here
NSLog(@"Hello, World! HotKey was pressed!");
[controller statusItemClicked:nil];
return noErr;
}
@end
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.