Re: background of NSButton and NSPopUpButton
Re: background of NSButton and NSPopUpButton
- Subject: Re: background of NSButton and NSPopUpButton
- From: Michael Becker <email@hidden>
- Date: Thu, 25 Nov 2004 12:00:29 +0100
Hi!
Am 25.11.2004 um 11:20 schrieb Don Willems:
Now I'm thinking of subclassing NSButtonCell and NSPopUpButtonCell,
but I'm not sure how to go about that.
Just subclass e.g. NSPopUpButton. This is itself an NSView-subclass, so
you can just override drawRect: like this:
- (void)drawRect:(NSRect)cellFrame {
// Creating a red background
[[ NSColor redColor] set];
NSRectFill([self bounds]);
[[ self cell] drawWithFrame:cellFrame inView:self];
}
The call to drawWithFrame:inView: will draw the PopUpButton. If you
want it to look like in the "bar" in Xcode, set the PopUpButton to be
not bordered.
Personally, though, I would go with your first idea (creating a
background view and placing non-bordered buttons on it) because this
way you can be sure that there are no graphical differences between
your button's background and the rest.
Cheers,
Michael
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden