1. Welcome to the new MacRumors forums. See our announcement and read our FAQ

New Tutorial on Global Hotkeys

Discussion in 'Mac Programming' started by iBonzo, Nov 28, 2005.

  1. macrumors newbie

  2. macrumors 603


  3. macrumors 601


    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?
  4. macrumors newbie

    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,

  5. macrumors 601


    Thanks, I will have a look at that.

Share This Page