FROM : Michael Becker
DATE : Thu Nov 25 12:00:29 2004
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
DATE : Thu Nov 25 12:00:29 2004
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
| Related mails | Author | Date |
|---|---|---|
| Don Willems | Nov 25, 11:20 | |
| Michael Becker | Nov 25, 12:00 | |
| Don Willems | Nov 25, 13:32 | |
| Michael Becker | Nov 25, 15:25 | |
| Don Willems | Nov 25, 22:11 | |
| Ryan Stevens | Nov 25, 23:47 | |
| Don Willems | Nov 26, 09:15 | |
| Don Willems | Nov 26, 09:22 |






Cocoa mail archive

