Not to worry, just realised what is happening. drawRect: gets called for ALL drawing operations in the view, not just background as I expected.
Carry on...

Regards,
Jason



On 11/07/2008, at 1:38 AM, Jason Wiggins wrote:

Hi everyone,

I have a Custom View in IB with an rounded NSTokenField (Focus ring set to none) and a rounded rect NSButton embedded in it. In XCode I have the Custom View class set to my subclass of NSView, with the following code:

- (void)drawRect:(NSRect)rect {
        NSGradient *gradient = nil;
        NSBezierPath *path = [NSBezierPath bezierPathWithRect:rect];
        [[NSColor blackColor] setFill];
        [path fill];

        // Create gloss gradient
gradient = [[NSGradient alloc] initWithStartingColor:[NSColor colorWithCalibratedWhite:1.0 alpha:0.3] endingColor:[NSColorcolorWithCalibratedWhite:1.0alpha: 0.2]];
        // Make a half-height rectangle
rect = NSMakeRect(rect.origin.x, (rect.origin.y + (rect.size.height)/2), rect.size.width, (rect.size.height)/2);
        
        path = [NSBezierPath bezierPathWithRect:rect];
        [gradient drawInBezierPath:path angle:-90];

        // Create upper highlight
        path = [NSBezierPath bezierPath];
[path moveToPoint:NSMakePoint(rect.origin.x, (rect.origin.y + rect.size.height))]; [path lineToPoint:NSMakePoint(rect.size.width, (rect.origin.y + rect.size.height))];
        [path closePath];
        [path setLineWidth:2];
        [[NSColor colorWithCalibratedWhite:1.0 alpha:0.2] setStroke];
        [path stroke];
}

The gradient draws as expected. The upper highlight also draws as expected in the view, but also on the NSTokenView and NSButton, which is unexpected and I don't know why this is so. Can anyone offer any info as to why this is the case?

Regards,
JJ
_______________________________________________

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/jwiggins%40optusnet.com.au

This email sent to [EMAIL PROTECTED]

_______________________________________________

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 [EMAIL PROTECTED]

Reply via email to