1

I have an application with an NSMenuItem that launches a separate window and I was wondering if it would also be possible to add a hot-key combination so that it would be possible to also invoke the NSWindow via that as well.

I was thinking that it's not possible, because wouldn't the application have to be 'Active' for a hot-key to work?

So, where should I be looking? Because, honestly, I'm not sure where to start.

Thanks!

Peter Hosey
  • 95,783
  • 15
  • 211
  • 370
Zrb0529
  • 800
  • 9
  • 25

1 Answers1

2

Edit: Try this Global Hotkeys

Your hot-key will only work when the app is active.

Click where the square is and press the combo of keys that you want to assign:

enter image description here

In case you mess up the combo of keys, you can clear it here (the "Clear" button at the bottom):

enter image description here

WrightsCS
  • 50,551
  • 22
  • 134
  • 186
  • Thanks, that's what I was thinking. In that case, is there any way to provide the functionality I was looking for? – Zrb0529 Feb 13 '11 at 01:59
  • Pressing the key combo will activate the menu, which will in turn open your NSWindow ;-) – WrightsCS Feb 13 '11 at 02:01
  • Now, is there anyway to keep my app persistently 'active' so that I can use the key combo while another app is active? Say, while I'm typing in Pages, I can control-shift-T to activate my app? – Zrb0529 Feb 13 '11 at 02:08
  • Updated my answer with a nice post on Glopbal hotkeys. – WrightsCS Feb 13 '11 at 02:16
  • There are Cocoa wrappers to make global hotkeys easier to set up: http://stackoverflow.com/q/3760318/30461 – Peter Hosey Feb 13 '11 at 03:43