• 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: NSPopUpButton, Bindings & separator items
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSPopUpButton, Bindings & separator items


  • Subject: Re: NSPopUpButton, Bindings & separator items
  • From: Eric Gorr <email@hidden>
  • Date: Wed, 4 Nov 2009 15:42:05 -0500


On Nov 4, 2009, at 3:38 PM, Matt Neuburg wrote:

On Wed, 4 Nov 2009 11:26:16 -0500, Eric Gorr <email@hidden> said:
I found this old message, but there was no answer posted and have the
same question...

http://lists.apple.com/archives/cocoa-dev/2005/Jan/msg00886.html

Is there a way to add separator Items to an NSPopUpButton using
bindings?

Here's an easy way; this is how I do it in my NotLight app.

First, #define MYMENUSEPARATORSTRING somewhere where everyone who needs to
can see it.


Now, subclass NSMenu and override as follows:

- (id <NSMenuItem>)addItemWithTitle:(NSString *)aString
                            action:(SEL)aSelector
                     keyEquivalent:(NSString *)keyEquiv {
   if ([aString isEqual: MYMENUSEPARATORSTRING]) {
       id <NSMenuItem> sep = [NSMenuItem separatorItem];
       [self addItem:sep];
       return sep;
   }
   return [super addItemWithTitle:aString action:aSelector
keyEquivalent:keyEquiv];
}

Now use that NSMenu subclass where needed. The bound object uses
addItemWithTitle to construct the menu, so our overridden method will be
called and a separator item will appear wherever MYMENUSEPARATORSTRING
occurs as the title in the bound content. m.

Cool. That looks like a good solution. _______________________________________________

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: 
 >Re: NSPopUpButton, Bindings & separator items (From: Matt Neuburg <email@hidden>)

  • Prev by Date: Re: Working around SBObject limitations
  • Next by Date: Re: Best pattern for similar objects with differences
  • Previous by thread: Re: NSPopUpButton, Bindings & separator items
  • Next by thread: Cocoa HTML template engine?
  • Index(es):
    • Date
    • Thread