Hi,

I'm building a transparent interface, and I'm stuck at NSButtonCell. An NSGradient with transparency is drawn in the cell. It overrides - isOpaque to return NO. The gradient is drawn nicely from drawWithFrame:, but if it's called from -highlight:withFrame:inView:, the gradient is drawn on top of everything that's already been drawn, resulting in an increasingly dark result when the button is pressed.

I feel I'm missing something fundamental here. I also hope that makes sense to everyone.

–––

- (void)highlight:(BOOL)flag withFrame:(NSRect)cellFrame inView: (NSView *)controlView
{
        if (flag) {
[self realDrawWithFrame:cellFrame inView:controlView gradient:pressedGradient];
        } else {
[self realDrawWithFrame:cellFrame inView:controlView gradient:buttonGradient];
        }
}

- (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView
{
        if (![self path]) {
                NSRect roundRect = NSInsetRect(cellFrame, 6, 6);
                roundRect.origin.y = roundRect.origin.y - 1;
                [self setPath:[NSBezierPath bezierPathWithRoundedRect:roundRect
                                                                                
                          xRadius:roundRect.size.height / 2
                                                                                
                          yRadius:roundRect.size.height / 2]];
        }
        
        if ([self isHighlighted]) { // Handle keyboard equivalent
                [self highlight:YES withFrame:cellFrame inView:controlView];
                return;
        }
[self realDrawWithFrame:cellFrame inView:controlView gradient:buttonGradient];
}

_______________________________________________

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