Re: Menu Items
Re: Menu Items
- Subject: Re: Menu Items
- From: David Blanton <email@hidden>
- Date: Mon, 1 Mar 2010 20:07:11 -0700
Ok. This is all very interesting. I did have acceptsFirstResponder
returning YES in the view that contains the action but it was not
being called.
Then the light bulb went off ... and by clicking in the view,
acceptsFirstResponder is called and then the validateMenuItem etc etc.
This does make sense in the context of the program as the menu item I
want to invoke is related to the view.
I'm gettin' it.
Thanks to all!
-db
On Mar 1, 2010, at 5:11 PM, Graham Cox wrote:
On 02/03/2010, at 10:47 AM, David Blanton wrote:
I connected a menu item to an action in First Responder. The action
is defined in a view.
This, apparently, does not define the Target as I put
validateMenuItem in the same view as the action but it is not called.
So, how does one define the Target?
The view and the Menu Item are in different nib files.
I really need to get a handle on how the best way to work with menus.
You are doing it right. First Responder defines the target as the
first responder currently within the app. When that's your view, its
action and menu validation method will be called; when that's not
your view, they won't.
So it sounds as if your view is not becoming first responder, rather
than a problem with the menu itself.
Note that the ability to click a view and have it respond to mouse
events does not indicate first responder is that view - FR really
pertains to keyboard input and other context-sensitive UI like
menus. Your view must return YES to -acceptsFirstResponder:
(inherited from NSResponder) which is NO by default. You'll probably
also want to set up how that view fits in with other potential
responders which involves hooking up the nextKeyView outlet or
letting the window calculate the key view loop.
--Graham
_______________________________________________
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