Re: Selecting submenu root
Re: Selecting submenu root
On Sun, Jun 30, 2002 at 05:33:35PM +0200, Benoit Widemann wrote:
>
There is a secondary problem, which, as far as I could find, has not
>
been mentioned in the archives (I'm getting careful). The Carbon menu
>
is not created when the Cocoa menu is created, but only the first
>
time the menu is actually dropped down. Until that moment, the
>
private call returns nil.
I'm pretty sure I mentioned this in the past, but maybe not. You can
add the menu to the menubar to force it to generate. I do it like
this:
- (void)mouseDown:(NSEvent *)theEvent;
{
NSMenu *menu = [[self cell] menu];
MenuRef mRef = _NSGetCarbonMenu(menu);
if (mRef == NULL) {
NSMenu *appMenu = [[[NSApp mainMenu] itemWithTitle: @""] submenu];
if (appMenu != nil) {
NSMenuItem *item = [appMenu addItemWithTitle: @"" action: NULL keyEquivalent: @""];
[appMenu setSubmenu: menu forItem: item];
[appMenu removeItem: item];
}
mRef = _NSGetCarbonMenu(menu);
}
// ... do stuff to mRef ...
--
=Nicholas Riley <email@hidden> | <
http://www.uiuc.edu/ph/www/njriley>
Pablo Research Group, Department of Computer Science and
Medical Scholars Program, University of Illinois at Urbana-Champaign
_______________________________________________
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.