Re: Hotkeys question
Re: Hotkeys question
- Subject: Re: Hotkeys question
- From: Matthew Formica <email@hidden>
- Date: Wed, 25 Sep 2002 13:27:16 -0700
I'm removing all the irrelevant lists that you cross-posted to from the to:
list on this email. Right now, the way to use HotKeys is to use the HotKey
API from Carbon. It works fine in Cocoa. Here's what you do (pulled from
another upcoming sample):
#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);
- (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!");
return noErr;
}
On 9/24/02 6:09 AM, "Ivan Gsmez" <email@hidden> wrote:
>
Hi,
>
I have, unless I think, a very simple question. Is it possible to set
>
an hotkey combination o however you'd like to call it so that my app
>
receive the notification that combination have been stroke despite the
>
app is frontmost? For example supose my app is running and my frontmost
>
app is photoshop or the Finder, and I want to register the alt+"up
>
arrow" for my app to change my desktop image. How can I do this?? I have
>
been looking into the help, examples.. even the Space app
>
(space.sourceforge.org) and I have found something similar but the
>
functions it uses don't appear in the docs
>
>
Thanks in advance.
>
>
Ivan Gsmez ------> Laf
>
_______________________________________________
>
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.
_______________________________________________
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.