Re: Key event handling theory
Re: Key event handling theory
- Subject: Re: Key event handling theory
- From: Greg Titus <email@hidden>
- Date: Fri, 4 Jan 2002 14:25:44 -0800
On Friday, January 4, 2002, at 01:40 PM, Brian Webster wrote:
OK, so does that mean that there's no "automatic" way to bind keys to
selectors, like by loading a key binding dictionary ala Project
Builder? That is, to create a new binding (e.g. for Shift-Return), I
would need to do that in interpretKeyEvents:? Also, I don't suppose
the default key bindings are documented anywhere (aside from digging
through the unicode values in the StandardKeyBinding.dict file), are
they?
No, I just thought you wanted to avoid a global change. Overriding
-interpretKeyEvents: to add the binding in a single class would make
shift-return do something different only in that class. Creating a
binding for shift-return to a new selector in a key binding dictionary
will set it for the whole application or globally -- which may be a good
thing or may be a bad thing depending on your intention. If you bind
shift-return to -frob:, for instance, then I think what will happen is
that it will work fine in your view as long as you just implement
-frob:, but I'd expect that NSTextView's would then do nothing when you
hit shift-return in them (since they don't have a -frob: method) instead
of acting like a normal return. That's just a guess though - I haven't
actually tried it.
As far as finding the default key bindings, I just implement
-doCommandBySelector:, put a breakpoint on it, and see what selector it
gets called with when I try my keystroke. :-)
Hope this helps,
--Greg