Re: How can I keep an NSPopUpButton open after the user selects a menu item?
Re: How can I keep an NSPopUpButton open after the user selects a menu item?
- Subject: Re: How can I keep an NSPopUpButton open after the user selects a menu item?
- From: Michael Ash <email@hidden>
- Date: Sun, 14 Jun 2009 12:35:04 -0400
On Sat, Jun 13, 2009 at 2:20 PM, Dennis
Hartigan-O'Connor<email@hidden> wrote:
> I have an NSPopUpButton providing the NSMenu for a status item with a custom
> view. The popup button displays a list of links. When the user selects a
> link from the list, the link is displayed in the user's browser (in the
> background).
>
> Naturally, the menu closes every time the user selects a link.
>
> I would like to change this: I want the menu to stay open while the user
> clicks on various links, all of which can be opened in the background. The
> menu can then go away when the user clicks elsewhere.
>
> How can this be accomplished? Should I subclass NSMenuItem and intercept the
> mouse clicks somehow? Overlay a transparent NSView on the popped-up menu
> and, again, intercept the clicks somehow? I make these suggestions blithely,
> but I would have trouble implementing either of these...pointers to the
> right methods for override would be appreciated.
This probably can't be done in any reasonable fashion. Subclassing
NSMenu classes won't work, because they're a thin wrapper around
Carbon menus and all the event tracking and such is handled internally
by Carbon. An overlay window could work but would be iffy.
However, I'd suggest that you shouldn't do this in the first place.
Don't break users' expectations. When they see a popup menu, they're
going to expect it to behave the way every other popup menu has
behaved since the dawn of time. Defying that expectation is a good way
to frustrate people and have them dislike your app.
Instead, use a different control. Maybe a custom control, but
something that will indicate to users that this behaves differently,
don't expect it to work like a popup menu. If you want to save space,
you could even pop up a window that holds the meat of your control,
just don't make it look like a popup menu.
Mike
_______________________________________________
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