Re: how to have a pop up menu from an ordinary button?
Re: how to have a pop up menu from an ordinary button?
- Subject: Re: how to have a pop up menu from an ordinary button?
- From: "Michael Ash" <email@hidden>
- Date: Fri, 8 Aug 2008 09:06:45 -0400
On Thu, Aug 7, 2008 at 5:53 PM, Rua Haszard Morris
<email@hidden> wrote:
> I am trying to implement a mini-size, square bevel button that pops up a
> menu, i.e. a popup button with a square appearance and mini size, but have
> not found a way to achieve this.
>
> NSPopupButton does not support square button appearance, and doesn't support
> setControlSize: (though it can of course be an arbitrary size).
>
> I have seen some suggestions for how to achieve this, for example making a
> NSPopupButton over the top of a square NSButton and setting the
> NSPopupButton transparent. This works but there are draw issues; sometimes a
> rounded white area appears around the NSButton (note that I have set the
> size & location of the popup button to match the button, so the clicks are
> handled appropriately). I also had a look at NSMenu popUpContextMenu:, but
> this did not seem appropriate, as it seems solely for right-click/context
> menus.
>
> How can I do this? I want to avoid having to write the mouse tracking code
> if at all possible, so the popup behaves exactly like a system one. I'm not
> clear on how to do this either..
This is where the view/cell division becomes handy. You can use an
NSPopUpButtonCell inside your view to do this. Don't ask it to draw
(since you're drawing other things), but when you get a mouse down
event you can pass it to the cell which will then pop up the menu in
the normal fashion.
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