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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to