Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

HiRez

macrumors 603
Jan 6, 2004
6,265
2,629
Western US
iBonzo said:
I wrote a tutorial on how to use Global Hotkeys in Cocoa.
Very cool, thanks a lot iBonzo! I don't have a need for this now, but I probably will someday.

Now, I have a somewhat related question for you all. I'm trying to have it so that I have hotkeys specific to a document window. For example, the space bar would toggle a pause/play method (independant for each document window). OK, so I have subclassed NSWindow and overridden keyDown: and that works fine. However, the problem is that I have editable text fields on this window, and as soon as I begin to edit one of the text fields, I lose my "window hotkeys" because it's stuck editing the text field. The text field will not resign editing (or focus, responder) status when I'm done editing (with return key). So how can I tell my app, or that document window at least, to end all editing and "defocus" all UI objects? I found a few methods that looked like they might do that, but they didn't work as advertised. Do I have to do something painful like subclass every editable UI object to accomplish this?
 

iBonzo

macrumors newbie
Original poster
Feb 24, 2005
12
0
I have not experimented with this, but as I was browsing through the docs, I think I came accross something that might work. I've just pulled it up right now in XCode and it looks like it might work. Open up your XCode and look at the Developer Documentation under Help. Do a search for "InstallEventHandler". This should bring up a page with explinations. Scroll down a little bit and read the Disccusion part. There is mention of InstallWindowEventHandler. Seems like it would be very similar to the turoial I wrote but just using a different function (InstallWindowEventHandler instead of InstallApplicationEventHandler) but do look into that function a little more to make sure.

Hope this helps,

-Dustin
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.