For the archives-

I ran into the problem where NSScrollviews from an NSCollectionViewItem's 
template view do not work properly in a collection view. This is a problem that 
was reported on this list back in 2007, and reported as a bug then, but is 
still broken in 10.6.2. I couldn't find a solution online so crafted one of my 
own. 

My gift to future coders who run into this problem:


@interface CBScrollView:NSScrollview
{
}
@end

@implementation CBScrollView

- (void) fixScrollerTargets
{
    if ([self verticalScroller] && [[self verticalScroller] target] != self)
    {
        [[self verticalScroller] setTarget:self];
    }
    
    if ([self horizontalScroller] && [[self horizontalScroller] target] != self)
    {
        [[self horizontalScroller] setTarget:self];
    }
}

- (id)initWithCoder:(NSCoder *)decoder
{
    if (self = [super initWithCoder:decoder])
    {
        [self performSelector:@selector(fixScrollerTargets) withObject:nil 
afterDelay:0];
    }
    
    return self;
}

- (void) dealloc
{
    [NSObject cancelPreviousPerformRequestsWithTarget:self 
        selector:@selector(fixScrollerTargets) 
        object:nil];

    [super dealloc];
}


@end

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please 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/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to