Go Back   The Apple Blog Community > Apple/Mac > Development
Register Social Groups iSpy Members List Search Today's Posts Mark Forums Read FAQ

Development XCode, Cocoa, and all other development

Reply
 
LinkBack Thread Tools Search this Thread
10-11-2006   #1 (permalink)
TAB Author
 
Join Date: Oct 2006
Posts: 3
michael is on a distinguished road
Apple did - so must you!
No, but seriously, only if you have an actual need for different scrollers. It's actually quite easy. Just a couple easy steps.

1) Create a new subclass of NSScroller.
2) Set the scroller of the view to be a new instance of this scroller
3) Decide which parts you want to draw different
* I'll show just the knob, but the rest are easy as well
4) Reimplement the following:
- (void)drawKnob;
...that's it!
5) Draw the knob ... here's just a solid color:

- (void)drawKnob {
[[NSColor redColor] set]; //set knob color to red
NSRect knobRect = [self rectForPart:NSScrollerKnob];
NSRectFill(knobRect);
}

You now have a red, rectangular scroller!!! Using this method, you can customize every part of the scroller, including the arrows and highlighting. Go nuts!

Michael

p.s. Please read the documentation before doing this. If you want to draw anything other than the arrows or the knob, you'll need to draw all of the rest using - (void)drawParts.
michael is offline   Reply With Quote
10-11-2006   #2 (permalink)
TAB Author
 
Join Date: Oct 2006
Posts: 1
dbachrach is on a distinguished road
That is awesome. Really simple hack.

I might throw that into one of my programs as an experiment.
dbachrach is offline   Reply With Quote
10-11-2006   #3 (permalink)
TAB Author
 
Join Date: Oct 2006
Posts: 3
michael is on a distinguished road
Maybe I could do a once a week coding trick. I wonder if there'd be an interest in that...
michael is offline   Reply With Quote
10-12-2006   #4 (permalink)
TAB Author
 
nicks's Avatar
 
Join Date: Oct 2006
Location: Denver, CO
Posts: 114
nicks is on a distinguished road
Send a message via AIM to nicks Send a message via MSN to nicks
Yeah Michael - that'd be pretty cool - in fact, work it up as a weekly TAB post. Then you could reference the post here, and address questions.... just a thought.
__________________
Sometimes I write for The Apple Blog. Mostly about Quicksilver.
nicks is offline   Reply With Quote
10-12-2006   #5 (permalink)
TAB Author
 
Join Date: Oct 2006
Posts: 3
michael is on a distinguished road
True. I could even take suggestions here on the boards as well.
michael is offline   Reply With Quote
12-01-2006   #6 (permalink)
Cashier
 
Join Date: Dec 2006
Posts: 17
axel is on a distinguished road
seems like a good idea
axel is offline   Reply With Quote
12-03-2006   #7 (permalink)
Business Consultant
 
sprint's Avatar
 
Join Date: Dec 2006
Posts: 141
sprint is on a distinguished road
Neat!
sprint is offline   Reply With Quote
12-03-2006   #8 (permalink)
Assistant Store Manager
 
baseballboy828's Avatar
 
Join Date: Nov 2006
Location: New Jersey
Posts: 2,223
baseballboy828 is on a distinguished road
Send a message via AIM to baseballboy828 Send a message via Skype™ to baseballboy828
Cool idea!
baseballboy828 is offline   Reply With Quote
12-04-2006   #9 (permalink)
Operator
 
Join Date: Dec 2006
Posts: 2
Disparity has disabled reputation
Has anyone noticed how a scroller will flicker when the view it contains (assuming the scroller to be part of a scrollview) no longer fits in the window (i.e. on a window resize)?
Disparity is offline   Reply With Quote
12-19-2006   #10 (permalink)
Mac Specialist
 
Join Date: Dec 2006
Posts: 429
llamame has disabled reputation
Thanks for the weekly coding tips.
llamame is offline   Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting 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


All times are GMT -6. The time now is 09:47 AM.




Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0 RC5
© 2004-2008