Re: NSPopUpButton, Bindings & separator items
Re: NSPopUpButton, Bindings & separator items
- Subject: Re: NSPopUpButton, Bindings & separator items
- From: Matt Neuburg <email@hidden>
- Date: Wed, 04 Nov 2009 12:38:26 -0800
- Thread-topic: NSPopUpButton, Bindings & separator items
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.
--
matt neuburg, phd = email@hidden, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
http://www.tidbits.com/matt/default.html#applescriptthings
_______________________________________________
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