• 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: Checking if a menu is visible??!?!?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Checking if a menu is visible??!?!?


  • Subject: Re: Checking if a menu is visible??!?!?
  • From: Peter Maurer <email@hidden>
  • Date: Tue, 2 Mar 2004 23:24:05 +0100

but I cannot find a way to check if a NSMenu is visible or not..

With a little help from carbon, this should be possible (at least for OS X versions whose NSMenus are based on carbon menus). First, get the NSMenu's menu reference via _NSGetCarbonMenu(NSMenu *) -- I have a NSMenu category that contains the following menuReference method...

extern MenuRef _NSGetCarbonMenu(NSMenu *);

- (MenuRef) menuReference {
MenuRef theMenuReference = _NSGetCarbonMenu(self);
if (theMenuReference==0) {
// this is necessary to make cocoa actually create the underlying carbon menu
NSMenu *theMainMenu = [NSApp mainMenu];
NSMenuItem *theDummyMenuItem = [theMainMenu addItemWithTitle: @"sub" action: NULL keyEquivalent: @""];
[theDummyMenuItem setSubmenu: self];
[theDummyMenuItem setSubmenu: nil];
[theMainMenu removeItem: theDummyMenuItem];
return _NSGetCarbonMenu(self);
}
return theMenuReference;
}

Then check for visibility...

NSMenu *theNSMenuInQuestion; // assume this is the menu you want to test
MenuTrackingData theMenuTrackingData;
if (GetMenuTrackingData([theNSMenuInQuestion menuReference], &theMenuTrackingData)==noErr) {
// the menu is visible
}

Does this help?

Peter Maurer.

__
http://www.petermaurer.de/butler/
_______________________________________________
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.


  • Follow-Ups:
    • Re: Checking if a menu is visible??!?!?
      • From: Rosyna <email@hidden>
References: 
 >Checking if a menu is visible??!?!? (From: "Jean-Olivier Lanctôt-D." <email@hidden>)

  • Prev by Date: Re: Resource fork question
  • Next by Date: Re: API for examining Quicktime Movies
  • Previous by thread: Checking if a menu is visible??!?!?
  • Next by thread: Re: Checking if a menu is visible??!?!?
  • Index(es):
    • Date
    • Thread