 |
 |
NSSliderCell Question
|
 |
|
 |
|
Mac Enthusiast
Join Date: Feb 2000
Location: Storrs,Connecticut, USA
Status:
Offline
|
|
I subclassed NSSliderCell and I overrode the - (void)drawBarInside  NSRect)aRect flipped  BOOL)flipped method in order to draw my own bar. I have no trouble drawing my own bar... the only problem is that under it the standard slider bar is drawn and it is 2 pixels longer than mine. (those two pixels are used for shadow of the slider nob and bar.) I want to make it such that it never draws the bar under mine. I thought that subclassing it and overriding that method would do the trick but it doesn't. Anyone have any idea how I can make it not draw the old bar.
|
|
|
| |
|
|
|
 |
|
 |
|
Dedicated MacNNer
Join Date: Jan 2001
Location: Virginia, US
Status:
Offline
|
|
You're not calling super, right?
Otherwise...
NSCell's main drawing method is -drawWithFrame:inView:. That method typically draws the border (if any) and calls -drawInteriorWithFrame:inView:. I assume NSSliderCell's implementation of the latter method is the one that calls -drawBarInside:flipped: and drawKnob:. Overriding drawBarInside:flipped: certainly used to work, but I'm not sure how things have changed with drawing MacOS X style sliders. You may try overriding one of the other two methods, while making sure to call -drawKnob correctly (something like [self drawKnob:[self knobRectFlipped:[theView isFlipped]]] I think).
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Enthusiast
Join Date: Feb 2000
Location: Storrs,Connecticut, USA
Status:
Offline
|
|
I'm not calling super. I guess that it must be an oversight on Apple's part. I made my slider longer so it covers the little shadow of the old one. I'll email the bug to Apple since this does seem to be a bug.
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Enthusiast
Join Date: Feb 2000
Location: Storrs,Connecticut, USA
Status:
Offline
|
|
Well, the strange behavior is not a bug. Here is the reply that I got from Apple:
drawBarInside:flipped: is gives you an opportunity to fill the interior of a slider. e.g. the colour gradient in a RGB colour panel. The bar itself will still be drawn. -[NSSliderCell drawBarInside:flipped:] does nothing.
To override the track drawing completely, override -[NSSliderCell drawWithFrame:inView:], don't call the super, draw your track, and call -[NSSliderCell drawKnob].
Andrew
__________________________________________________ ________________
A n d r e w P l a t z e r
A p p l i c a t i o n F r a m e w o r k s
A p p l e
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |