Keyboard loop (tabbing order) in drawers
Keyboard loop (tabbing order) in drawers
- Subject: Keyboard loop (tabbing order) in drawers
- From: Bill Cheeseman <email@hidden>
- Date: Thu, 20 May 2004 15:30:34 -0400
Like others before me, I was having trouble making custom keyboard loop
tabbing order work correctly in a drawer. I finally found a way to make it
work, and I thought I would share it here in case it hasn't been noted
before (I couldn't find a solution in the archives). If there is some more
obvious solution that I overlooked, please let me know.
Cocoa apparently ignores custom keyboard loops that are set up in IB in
windows or tab views, if the window or tab view doesn't have an initial
first responder set. But IB doesn't provide a way (that I can find) to set
an initial first responder for a drawer. Now, I know from past work that a
drawer's contentView is contained in a window, although it is a window you
hardly ever notice -- NSDrawer.h has a private instance variable for this
window, but it is not exposed in an NSDrawer accessor method and it
apparently isn't accessible in IB. But you can access it by getting the
drawer's contentView and using it's window accessor. So in my -awakeFromNib
method I set the drawer's contentView's window's initial first responder to
one of the controls in the drawer -- and my custom keyboard loop magically
started working.
My -awakeFromNib code looks like this, where 'drawer' is variable referring
to my NSDrawer instance:
[[drawer contentView] window] setInitialFirstResponder:[drawer
contentView]]
Seems like this is a bug -- or two bugs. (1) You can't set the initial first
responder of a drawer's contentView's window in IB. Normally, of course, one
shouldn't mess with that window, but instead work solely through the drawer
object, but in this case it seems to be necessary. (2) Cocoa doesn't
automatically set a drawer window's contentView as the the drawer window's
initial first responder.
--
Bill Cheeseman - email@hidden
Quechee Software, Quechee, Vermont, USA
http://www.quecheesoftware.com
The AppleScript Sourcebook -
http://www.AppleScriptSourcebook.com
Vermont Recipes -
http://www.stepwise.com/Articles/VermontRecipes
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.