Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSScrollView custom thumbs



I found that doing just that wasn't enough at least if the NSScrollView comes from a nib. Simply calling setVerticalScroller or setHorizontalScroller with an instance of my scroller when the NSScrollView was created via a nib resulted in scrollbars that didn't draw or behave correctly. Instead I subclassed NSScrollView, in addition to subclassing NSScroller, and implemented initWithCoder: method in my NSScrollView subclass as

- (id) initWithCoder: (NSCoder *) decoder
{
BOOL useSetClass = NO;
BOOL useDecodeClassName = NO;

if ( [decoder respondsToSelector: @selector (setClass:forClassName:)] ) {
useSetClass = YES;
[(NSKeyedUnarchiver *) decoder setClass: [MyScroller class] forClassName: @"NSScroller"];

}
else if ( [decoder respondsToSelector: @selector (decodeClassName:asClassName:)] ) {
useDecodeClassName = YES;
[(NSUnarchiver *) decoder decodeClassName: @"NSScroller" asClassName: @"MyScroller"];
}


	self = [super initWithCoder: decoder];

if ( useSetClass ) {
[(NSKeyedUnarchiver *) decoder setClass: [NSScroller class] forClassName: @"NSScroller"];
}
else if ( useDecodeClassName ) {
[(NSUnarchiver *) decoder decodeClassName: @"NSScroller" asClassName: @"NSScroller"];
}

return self;
}


Note: this code assumes nothing has already replaced NSScroller.

BTW: I also found that drawParts for my scroller subclass never got called.

Milt


On Dec 17, 2006, at 09:16, I. Savant wrote:


You'll need to subclass NSScroller and override -drawKnobs - drawParts and -drawArrow:highlight: (along with their supporting methods) and draw your own stuff.


--
I.S.


On Dec 17, 2006, at 11:32 AM, Lorenzo wrote:

Hi,
I would like to customize the thumbs of a NSScrollView and put e.g.
something like the iTunes' thumbs.
I suppose there should be 3 images to compose a thumb.
How to change those images?


Best Regards -- Lorenzo email: email@hidden

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/idiotsavant2005% 40gmail.com


This email sent to email@hidden

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden
References: 
 >NSScrollView custom thumbs (From: Lorenzo <email@hidden>)
 >Re: NSScrollView custom thumbs (From: "I. Savant" <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.