Re: Handling key equivalents in a controller class?

2008-07-21 Thread Nathan Vander Wilt
Jens – I've been wanting to do similar key handling in my controller class (rather than view classes), so I'm glad I'm not the only one not fully grokking the responder chain. I got some helpful responses to my more specific question, but without loss of generality. Especially:

Re: Handling key equivalents in a controller class?

2008-07-21 Thread Matt Neuburg
On Sat, 19 Jul 2008 12:34:45 -0700, Jens Alfke [EMAIL PROTECTED] said: On 19 Jul '08, at 8:52 AM, Matt Neuburg wrote: Try it and see. Let's say we want to catch Esc directed to the window as a whole (to exit full screen mode, if I recall your example). So what I would do is to insert an

Re: Handling key equivalents in a controller class?

2008-07-19 Thread Matt Neuburg
On Thu, 17 Jul 2008 09:31:53 -0700, Jens Alfke [EMAIL PROTECTED] said: On 16 Jul '08, at 2:53 PM, Matt Neuburg wrote: Implement keyDown: in the NSWindowController? keyDown: only gets sent to the key view, whether or not it handles that keystroke. Since the method returns void, there's no way

Re: Handling key equivalents in a controller class?

2008-07-19 Thread Jens Alfke
On 19 Jul '08, at 8:52 AM, Matt Neuburg wrote: Try it and see. Let's say we want to catch Esc directed to the window as a whole (to exit full screen mode, if I recall your example). So what I would do is to insert an NSResponder instance behind the window in the chain and implement

Re: Handling key equivalents in a controller class?

2008-07-19 Thread Jeff Johnson
On Jul 19, 2008, at 2:34 PM, Jens Alfke wrote: On 19 Jul '08, at 8:52 AM, Matt Neuburg wrote: Try it and see. Let's say we want to catch Esc directed to the window as a whole (to exit full screen mode, if I recall your example). So what I would do is to insert an NSResponder instance

Re: Handling key equivalents in a controller class?

2008-07-19 Thread I. Savant
I had already tried implementing keyDown: in my controller object, which is the window's delegate, to no avail. But that class is just a direct subclass of NSObject, not NSResponder or NSWindowController. I tried changing its superclass to NSResponder, but that didn't help. (I've never

Re: Handling key equivalents in a controller class?

2008-07-17 Thread Andy Lee
On Jul 16, 2008, at 2:43 PM, Kyle Sluder wrote: Except what happens if a field editor is key? Then the editor swallows all keys, including Esc. Or if it doesn't do this by default, Esc is one of the keys that it can swallow because NSTextView uses it as the autocomplete hotkey. Didn't this

Re: Handling key equivalents in a controller class?

2008-07-17 Thread Jens Alfke
On 17 Jul '08, at 10:45 AM, Andy Lee wrote: I'd add a (BOOL)handleMyKeyDown: method in a category of NSObject, and override keyDown: in NSApplication to traverse windows, delegates (perhaps including control delegates), and descendant views until something returns YES. Well, if I'm

Handling key equivalents in a controller class?

2008-07-16 Thread Jens Alfke
I've run into this problem a few times now: I have an NSWindowController subclass that manages a window. I want to handle certain hot-keys in this window, for example Esc to exit full-screen mode, or maybe use letter keys to switch tools as in Photoshop. Where do I put the handler for

Re: Handling key equivalents in a controller class?

2008-07-16 Thread Kyle Sluder
On Wed, Jul 16, 2008 at 2:00 PM, Jeff Johnson [EMAIL PROTECTED] wrote: NSWindow is an NSResponder, so you could create an NSWindow subclass and override performKeyEquivalent: or keyDown: there. Except what happens if a field editor is key? Then the editor swallows all keys, including Esc. Or

Re: Handling key equivalents in a controller class?

2008-07-16 Thread Jeff Johnson
On Jul 16, 2008, at 1:43 PM, Kyle Sluder wrote: On Wed, Jul 16, 2008 at 2:00 PM, Jeff Johnson [EMAIL PROTECTED] wrote: NSWindow is an NSResponder, so you could create an NSWindow subclass and override performKeyEquivalent: or keyDown: there. Except what happens if a field editor is key?

Re: Handling key equivalents in a controller class?

2008-07-16 Thread Matt Neuburg
On Wed, 16 Jul 2008 10:05:52 -0700, Jens Alfke [EMAIL PROTECTED] said: I've run into this problem a few times now: I have an NSWindowController subclass that manages a window. I want to handle certain hot-keys in this window, for example Esc to exit full-screen mode, or maybe use letter keys to