Transparent NSImage in NSButton
Transparent NSImage in NSButton
- Subject: Transparent NSImage in NSButton
- From: Aandi Inston <email@hidden>
- Date: Tue, 19 Aug 2014 11:18:15 +0100
I'm wondering what the "right" way is to use transparent images in an
NSButton (not using Interface Builder as this is a port of a platform
independent dialog library, which is also required to work back to 10.5).
Transparent images here = PDF loaded as NSImage which do not paint their
entire canvas.
These NSButton elements sit in an NSWindow with default background Color.
The problems:
- sometimes (as yet unclear when but it might have started when we started
to set image scaling) the first paint of the image has a
white background.
- subsequent repaints (e.g. when the button is clicked) repaint on the
window's background, i.e. seemingly as required
- each subsequent repaint does not clear the background. This results in
repeated clicks making the image darker and darker, or if there is an
alternate image we are left with the shadow of both.
Key definitions
- NSButton setImagePosition:NSImageOnly setBordered:no and
[[button cell] setImageScaling:NSImageScaleProportionallyUpOrDown]
- For a single image, NSButton setImageType:NSMomentaryLightButton
- For two image, NSButton setImageType:NSToggleButton or
NSMomentaryChangeButton
I'm wondering if I need to add code that causes the button area to be
erased or repainted in the background colour before it is painted. Or
perhaps use a different control/view type altogether (NSImageView?) and
mandate non-transparent images where button functionality is actually
needed.
Thanks in advance.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden