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 ([email protected])

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