• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Finder-like color label menu item in Cocoa?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Finder-like color label menu item in Cocoa?


  • Subject: Re: Finder-like color label menu item in Cocoa?
  • From: James Bucanek <email@hidden>
  • Date: Sun, 23 Jul 2006 17:39:54 -0700

Seth Willits wrote on Sunday, July 23, 2006:

>On Jul 23, 2006, at 4:14 PM, James Bucanek wrote:
>
>> I assumed that I could simply add the following code to my
>> application to get started:
>>
>> static void sInstallCarbonLabelMenuItem( void )
>> {
>>     MenuRef layerMenuRef;
>>     layerMenuRef = GetMenuHandle(MENU_LAYER);
>>
>>     // place a custom menu item view in the menu
>>     HIViewRef   view;
>>     HIViewRef   subview;
>>     HIMenuGetContentView( layerMenuRef, kThemeMenuTypePullDown,
>> &view );
>>     HILabelViewCreate( layerMenuRef, 3, view, &subview,
>> gAppDelegate, @selector(setLayerTint:) );
>>     HIViewSetVisible( subview, true );
>> }
>>
>> But the call to GetMenuHandle() returns NULL. I have a top-level
>> submenu named "Layers" with a tag of 1300 defined in my NIB. From
>> the Carbon documentation, GetMenuHandle(1300) should return me a
>> MenuRef to that menu item. I also know that the menu is valid at
>> this point becuase it is where I perform other modifications to the
>> menu bar. Is there some other Carbon stuff I have to do first?
>
>There's a private function you probably want to use:
>
>
>extern MenuRef _NSGetCarbonMenu( NSMenu *menu);

Doesn't seem to help/work. I tried

    extern MenuRef _NSGetCarbonMenu( NSMenu* menu );
    MenuRef mainMenuRef = _NSGetCarbonMenu([NSApp mainMenu]);

and mainMenuRef is set to 0.

Thinking that you might have meant NSMenuItem, I tried

    extern MenuRef _NSGetCarbonMenu( NSMenuItem* menu );
    NSMenuItem* layersMenuItem = [[NSApp mainMenu] itemWithTag:MENU_LAYER];
    MenuRef layerMenuRef = _NSGetCarbonMenu(layersMenuItem);

and layerMenuRef gets set to 0.

Besides, "private" functions make me really nervous.

>I'm interested in the end product once you get it working. :)

So am I. :)

--
James Bucanek
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Finder-like color label menu item in Cocoa?
      • From: Pascal Pochet <email@hidden>
    • Re: Finder-like color label menu item in Cocoa?
      • From: Rosyna <email@hidden>
References: 
 >Re: Finder-like color label menu item in Cocoa? (From: Seth Willits <email@hidden>)

  • Prev by Date: Re: Finder-like color label menu item in Cocoa?
  • Next by Date: Re: NSImage From Client to Server
  • Previous by thread: Re: Finder-like color label menu item in Cocoa?
  • Next by thread: Re: Finder-like color label menu item in Cocoa?
  • Index(es):
    • Date
    • Thread