• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Problems using Hotkeys and references to an NSSearchField
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >Problems using Hotkeys and references to an NSSearchField (From: "Lars Pettersson" <email@hidden>)

  • Prev by Date: Re: @synchronized produces warning on messages to super
  • Next by Date: Re: @synchronized produces warning on messages to super
  • Previous by thread: Problems using Hotkeys and references to an NSSearchField
  • Next by thread: Re: Problems using Hotkeys and references to an NSSearchField
  • Index(es):
    • Date
    • Thread