> I'd like to populate a menu bar menu items submenu during opening.
> In my Carbon Event Handler I did this with
> case kEventMenuPopulate:
> case kEventMenuOpening:
> In my nib I have added a submenu to the menu bar. I gave the menu a
> custom class "menu_flyhandler" which is subclassed from NSMenu.
> What do I do now?
> I'm fine in Carbon and feel well in IB. I'm interested in the basic
> steps to do so. Like add this and there, connect this.
> I'm stuck cause the ususal Menu functions do not appear in the
> inspector.
>
Are you trying to populate the submenu at runtime, or do you want to
define it in advance, using IB? Either way, I don't see any need to
subclass NSMenu. That class already has a wealth of methods for adding
and deleting menu items on the fly, and for managing submenus. If you
know ahead of time what menu items you want, you can do it all in IB.
You can manage submenus the same way as main menus.
--
Dave Seaman
Third Circuit ignores precedent in Mumia Abu-Jamal ruling.
<http://www.indybay.org/newsitems/2008/03/29/18489281.php>
Your app should have a principal class defined in the nib file ("Files
Owner", which you can select the class for in the inspector). Typically,
for something like this, you put the population function in an -
awakeFromNib method.
If you are writing a document-based application, the approach will be
slightly different. You can subclass NSDocumentController and override
the -init method to include a menu populator method, or use the -
windowControllerDidLoadNib method in your NSDocument subclass to make
sure the menu has been populated.
You can override the -init method for your menu_flyhandler, but be aware
that it will get called twice (not sure why that is). Remember to pass
the init to super first. Most -init overrides are written
- (id)init {
if ( self = [super init] ) {
// custom initialization
} }
return self;
}