How to identify a menu item?
How to identify a menu item?
- Subject: How to identify a menu item?
- From: Manfred Lippert <email@hidden>
- Date: Sun, 03 Mar 2002 14:06:10 +0100
Hi,
I often have the problem to identify a specific menu item. Mostly in
implementations of the validateMenuItem method.
I solved it this way - it works, but I think it is too complicated to be the
"true way":
1.) I created for every interesting menu item an Outlet in my AppController
(the NSApp delegate) which is located in the same NIB file as my menu bar,
and connected every menu item with its Outlet.
2.) I wrote a simple "getter" method for each Outlet (= menu item) in my
AppController, for example:
- (NSMenuItem *) getPrintMenuItem {
return printMenuItem;
}
3.) In my validateMenuItem method I do the following, for example to test if
the item is the print menu item:
- (BOOL) validateMenuItem:(NSMenuItem *)item {
AppController *appController = [NSApp delegate];
if (item == [appController getPrintMenuItem]) {
// ...
}
// ...
}
Is there an easier way to do this? It is much work, especially if you have
many menu items to validate ...
I think there must be something easier, because all other things in Cocoa
are so extremely simple and cool. ;-)
Regards,
Mani
_______________________________________________
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.