Problems using Hotkeys and references to an NSSearchField
Problems using Hotkeys and references to an NSSearchField
- Subject: Problems using Hotkeys and references to an NSSearchField
- From: "Lars Pettersson" <email@hidden>
- Date: Wed, 25 Jan 2006 09:13:16 +0100
- Thread-topic: Problems using Hotkeys and references to an NSSearchField
Hi to all,
Wondering if anyone could give me a clue about how to correct implement
a Hot Key Handler (Using the Carbon RegisterEventHotKey event from
Cocoa) that handles references to an NSSerachField object inside an
NSWindow?
The background is that I'm developing a small application in Cocoa using
Xcode 2.2 on Mac OS Tiger 10.4.4. The application should be used to copy
and translate selected text from any other MacOS X application by
pressing a pre-defined hotkey. I'm using the Carbon event
RegisterEventHotKey to trigger the hotkey and this part seems to work
fine. But the problem shows up when I would like to set a value in an
NSSearchField after the hotkey have been pressed.
OSStatus MyHotKeyHandler(EventHandlerCallRef nextHandler,EventRef
theEvent, void *myObjectPointer);
I can't refer any of the Object-C instances / methods defined in the Nib
from MyHotKeyHandler, and retrieve a compile error if I try to use
something like [phraseField setStringValue:@"xxx"]. As far as I
understand, you can't directly use Object-C variables from here, like
self etc.
I've done my bindings and It works fine to set the value for the
SerachField from any other functions in the application by simple
writing [phraseField setStringValue:@"any value"];
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?
If anyone has any suggestions of how to solve this, or even better: a
working code example from a HotKeyHandlar that manipulates the conten in
an NSTextField or NSSerachField, please let me know.
Thank you,
Lars
(An RegisterEventHotKey could be found here )
http://www.dbachrach.com/blog/2005/11/program-global-hotkeys-in-cocoa-ea
sily.html
<http://www.dbachrach.com/blog/2005/11/program-global-hotkeys-in-cocoa-e
asily.html>
_______________________________________________
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