Re: custom menu for NSPopUpButton
Re: custom menu for NSPopUpButton
- Subject: Re: custom menu for NSPopUpButton
- From: "Ken Ferry" <email@hidden>
- Date: Wed, 7 Nov 2007 09:56:06 -0800
You'd use a single menu item with a single custom palette view, and
the palette would have two dimensionally arranged swatches. Each
swatch could be subview if you found it convenient.
Take a look at the TrackView class in the MenuItemView sample code,
<http://developer.apple.com/samplecode/MenuItemView/index.html>. This
demonstrates something like the 'label' item in Finder's File menu.
It sounds like you want to draw the selected menu item color behind
whichever swatch is rolled over.
-Ken
Cocoa Frameworks
On Nov 7, 2007 8:42 AM, Kurt Sutter <email@hidden> wrote:
> Ken
>
> Thanks, this is helpful. I was not aware of setView.
>
> However, as I understand this, using setView would allow me to
> replace each menu item by something else, but the items would still
> remain arranged vertically above each other. As I mentioned, I want
> the items of the menu to be two-dimensionally arranged, e.g. in ten
> rows and ten columns. To do that, I would have to go the hard way.
> Right?
>
> Regards, and thanks again
>
> Kurt
>
>
>
> On 07.11.2007, at 07:03, Ken Ferry wrote:
>
> > Hi Kurt,
> >
> > In Leopard, you would do this by writing a custom view for your
> > palette and adding it to a menu item via the new API -[NSMenuItem
> > setView:].
> >
> > http://developer.apple.com/releasenotes/Cocoa/AppKit.html#NSMenu
> >
> > There isn't support for menu customization of this scope prior to
> > Leopard. On the other hand, you could do this on prior system
> > versions by not using a menu. You could make a custom view that
> > stamps out a pop up for its drawing, and handles mouse clicks (and
> > keyboard nav!) itself by popping up a window with your palette. This
> > is definitely work, but it's doable.
> >
> > -Ken
> >
> > On Nov 6, 2007 11:55 AM, Kurt Sutter <email@hidden> wrote:
> >> I have an NSPopUpButton in a window created with Interface Builder. I
> >> would like to attach a custom menu to that button. The custom menu is
> >> e.g. a two-dimensional color palette or some other non-standard,
> >> usually two dimensional arrangement of items for the user to select.
> >> Can anyone give me advice how to do that? I have read somewhere that,
> >> if you want a custom menu in Cocoa, you have to use a Carbon menu.
> >> This would come in handy because I already do have the carbon code
> >> for
> >> those custom menus. But I have no clue how to attach the Carbon menu
> >> to that button. Or is there some other recommended way to create a
> >> custom menu under Cocoa and attach it to a button?
> >>
> >> Any advice is appreciated.
> >>
> >> Best regards
> >>
> >> Kurt Sutter
> >>
> >> _______________________________________________
> >>
> >> 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