Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > NSSliderCell Question

NSSliderCell Question
Thread Tools
Mac Enthusiast
Join Date: Feb 2000
Location: Storrs,Connecticut, USA
Status: Offline
Reply With Quote
Apr 9, 2001, 05:54 PM
 
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
Reply With Quote
Apr 12, 2001, 01:14 PM
 
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).

     
Dalgo  (op)
Mac Enthusiast
Join Date: Feb 2000
Location: Storrs,Connecticut, USA
Status: Offline
Reply With Quote
Apr 12, 2001, 04:19 PM
 
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.
     
Dalgo  (op)
Mac Enthusiast
Join Date: Feb 2000
Location: Storrs,Connecticut, USA
Status: Offline
Reply With Quote
Apr 14, 2001, 11:33 AM
 
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
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 03:00 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2