Re: Problems using Hotkeys and references to an NSSearchField
Re: Problems using Hotkeys and references to an NSSearchField
- Subject: Re: Problems using Hotkeys and references to an NSSearchField
- From: Daniel Jalkut <email@hidden>
- Date: Wed, 25 Jan 2006 11:32:57 -0500
Your actual question is very brief, but it took a lot of reading to
get to. Everything in your post about NSSearchField or whatever is
irrelevant to the question.
On Jan 25, 2006, at 3:13 AM, Lars Pettersson wrote:
My guess is that you have to add an object references when calling
InstallApplicationEventHandler, that later should be used in the
HotKeyHandler function to refer to the actual NSSearchField. But I
can't
find out what object to use or how to implement a correct solution.
Should I use Self? NSWindow? NSApplication?
Your guess is correct. You need to pass some reference to an
objective-C object in to the hot key handler, so it has somebody to
notify.
Pass whatever you want. You're the programmer. Often "self" makes
sense. In this case if you just want it to deal directly with the
search field, that's fine, too.
Typically you just cast the value of the userData parameter to the
type of object you know it is (you provided it!):
OSStatus MyHotKeyEventHandler(EventHandlerCallRef inHandlerCallRef,
EventRef inEvent, void *inUserData)
{
NSSearchField* mySearchField = (NSSearchField*)inUserData;
[mySearchField setStringValue:@"blah"];
}
Just make sure you understand the life-cycle of whatever object
you're passing in to the hot key event handler. You need to
guarantee that it will remain retained until the hot key handler is
uninstalled.
Daniel
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden