Re: Keyboard Loop in Programmatically Created Window
Re: Keyboard Loop in Programmatically Created Window
- Subject: Re: Keyboard Loop in Programmatically Created Window
- From: Jerry Krinock <email@hidden>
- Date: Tue, 3 Apr 2007 16:13:11 -0700
On 2007 Apr, 03, at 11:49, Sean McBride wrote:
Users can change keybindings, and ASCII 9 isn't necessarily what
should
invoke the 'tab' behaviour.
The default keybindings are here:
/System/Library/Frameworks/AppKit.framework/Resources/
StandardKeyBinding.dict
See also:
<http://developer.apple.com/documentation/Cocoa/Conceptual/
EventOverview/
TextDefaultsBindings/chapter_9_section_2.html#//apple_ref/doc/uid/
20000468-611005>
Yes, I had a feeling there was probably another layer in there. I
was hoping that I had jumped over that lower layer by using -[NSEvent
characters] instead of -[NSEvent keyCode]. The documentation for -
characters does say: "These characters are ^derived from a keyboard
mapping^ that associates various key combinations with Unicode
characters." But after changing my Mac's key binding of insertTab:
from "\t" to 'z', and relaunching my app, I see that Sean is
correct. Typing in an NSTable in another window, hitting 'tab' now
inserts a tab instead of moving to the next cell, and hitting 'z' now
moves to the next cell. This is as expected. But in my subclassed
window, hitting 'tab' still moves focus to the nextKeyView, and
hitting 'z' does nothing.
I fear that I have two ugly alternatives to make my class "key-
binding independent":
1. Instead of over-riding sendEvent:, instantiate all of the
window's tab-able controls as subclasses, and in all these
subclasses, over-ride insertTab: and insertBacktab:.
2. Over-ride sendEvent: as I have, but, when the app launches, read
the file /System/Library/Frameworks/AppKit.framework/Resources/
StandardKeyBinding.dict to find what are the keys for values
@"insertTab:" and @"insertBackTab", and then use these keys in my
sendEvent: over-ride to match -[NSEvent characters].
Neither one of these alternatives makes for a nice self-contained
class, although number 2 maybe could be if I used a few old-fashioned
'static' variables. I hope that someone can please tell me that I'm
all wrong and that there is an easier way :(
Jerry
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden