Gnarly problem getting a NSResponder inserted into the action chain.
Gnarly problem getting a NSResponder inserted into the action chain.
- Subject: Gnarly problem getting a NSResponder inserted into the action chain.
- From: David Hoerl <email@hidden>
- Date: Mon, 22 Oct 2007 12:32:55 -0400
The app has windows with several custom views in them that should
respond to certain menu commands and keyboard input. Normally, one of
them is the first responder.
However, I have a combo box in the toolbar, and a NSTextView in a
drawer, and either can become the first responder when clicked into.
However, even if one of these is being edited, one of the images in
the window is still primary, and should also be in the action
responder chain (to respond to menu items).
So, when window's first responder is not one of these images (and
thus one of the text controls), I had the windowController's
nextResponder return the active image view. This sort of works, but
it results in a responder chain loop; the image view returns its
superview, back to the window, then the window controller, and again
back to the image view through the windowController nextResponder
outlet.
The hack I came up with is to have the windowController set a
"oneshot" flag for the image view; with this flag set, the image
returns nil when asked for its nextresponder, then it resets the
flag. The end result is that everything now appears to be working as
desired.
However, this solution leaves me a bit queasy, so I'm hoping someone
on the list has hit this same problem and has a better solution to
offer.
David
PS: I already read and reread the "Event Architecture" document that
describes the Responder Chain looking for some other alternative.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please 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