• 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: Custom NSMenu
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Custom NSMenu


  • Subject: Re: Custom NSMenu
  • From: Graham Cox <email@hidden>
  • Date: Mon, 16 Jun 2008 13:31:05 +1000

I think the short answer is: you can't (in Cocoa).

This has always been a bit tricky to implement, going right back to the original Mac OS c. 1984. While a pop-up is down and tracking it is handling its own event loop so is probably ignoring mouseEntered: and mouseExited: events. If your menus are completely custom anyway, you might be able to achieve the same result by using a temporary window and handling the events yourself. If they are mostly standard menu items, you'd have a lot of work to do to emulate the standard appearance (and be at the mercy of future changes).

It would probably be worth filing a feature enhancement request (such as getting notifications when menu tracking leaves the menu area itself) so that implementing custom menubars, etc. is at least possible.

Another possibility is to drop down to the Carbon menu manager to handle this, where there are some supported lower-level hooks for doing this. It's been a long time since I looked at that but I did port an app to Carbon/OS X back in 2000 that implemented a custom menubar like this and got it working OK. Unfortunately that code was proprietary and I do not have a copy so I can't advise on the details. I do know the same code is still working on Leopard though!


Graham



On 16 Jun 2008, at 1:09 am, Marco Cassinerio wrote:

I've to build e custom menu like this:

| "menu item 1" | "menu item 2" | "menu item 3" |

Every menu item is a NSPopUpMenu's subclass with a custom image displayed. When the user left-click on a menu item a PopUpMenu is displayed.
What i would is let the user to left-click and move mouse over the others menu item to display their respective popupmenu.


I tried to add a tracking rect to every menu item but mouseEntered: and mouseExited: events seem to not be delivered when popupmenu is opened.
Is it a correct behaviour? How can i track mouse events when a popupmenu is opened?


Marco.
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Custom NSMenu (From: Marco Cassinerio <email@hidden>)

  • Prev by Date: Re: NSOutlineView threading problem
  • Next by Date: Re: Initializing font size in UITextField
  • Previous by thread: Custom NSMenu
  • Next by thread: Static Functions and Variables
  • Index(es):
    • Date
    • Thread