Re: Custom Menus
Re: Custom Menus
- Subject: Re: Custom Menus
- From: Frank Vercruesse <email@hidden>
- Date: Thu, 17 Jan 2002 03:25:35 +0100
Hi,
Here's how I make a Carbon MenuRef from a Cocoa NSMenu. Not really what
you want, but it's a start :) As always this private API stuff is
absolutely unsupported, so use at your own risk!
@interface NSMenu (NSMenu_Top_Secret)
- (id)_menuImpl;
@end
extern void _NSGetMenuItemForCommandKeyEvent( NSMenu *menu, void *whoCares,
void *whoCares, void *whoCares);
extern MenuRef _NSGetCarbonMenu( NSMenu *menu);
{
NSMenu *menu;
NSMenuItem *mItem;
MenuRef carbonMenu;
int dummy, dummy2;
menu = [[NSMenu alloc] initWithTitle:@""];
[menu setAutoenablesItems:NO];
mItem = [[NSMenuItem alloc] initWithTitle:@"" action:nil keyEquivalent:@""
];
[menu addItem:mItem];
[mItem setTarget:self];
[mItem release];
[menu _menuImpl];
_NSGetMenuItemForCommandKeyEvent( menu, NULL, &dummy, &dummy2);
carbonMenu = _NSGetCarbonMenu( menu);
ChangeMenuItemAttributes( carbonMenu, 1, kMenuItemAttrHidden, 0);
...
}
Hope this helps.
Frank
--
http://www.vercruesse.de
On Mittwoch, Januar 16, 2002, at 11:43 Uhr, email@hidden wrote:
I don't mean a Menu Extra, merely a menu with an NSView instead of the
standard item list. The Volume extra was just an example of something
that used a view in a menu. Basically, I'm wondering is it possible to do
something similar to a Carbon MDEF, but I want to do it from cocoa.
Unless of course there is some way to use an actual carbon MDEF from a
Cocoa App, but I was under the impression that it's not possible to mix
UI code between the two.
-Akiva
On Sunday, January 13, 2002, at 05:55 PM, Finlay Dobbie wrote:
On Sunday, January 13, 2002, at 07:27 pm, email@hidden wrote:
How do I create a menu with a custom view like in the Volume Menu Extra?
Thanks.
What do you mean with a custom view?
The Menu Extra API is not public, Apple reserves it for its own use.
-- Finlay