Re: Custom NSButton image effects for pressed/disabled
Clever idea creating an image with the two images and the title in it, but then the title would be pressed/darkened too and not shown in white on blue background… /Lars > Den 13. dec. 2018 kl. 01.46 skrev Jens Alfke : > > > >> On Dec 11, 2018, at 5:03 PM, Lars C. Hassing wrote: >> >> If I assign an image to an NSButton it is displayed with nice pressed and >> disabled effects. >> >> In my custom NSButton, that should display image1+title+image2, I override >> drawRect:, but how do I obtain the EXACT SAME system effects for the two >> images? > > Don’t override drawRect; you should use a custom NSButtonCell instead. (In > general NSButton is just a wrapper around NSButtonCell.) > > That itself may solve your problem. If not, you could work around it by > creating a single NSImage (at runtime) with the two images and the title in > it, and just setting that as the button’s image. > > —Jens > ___ 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Custom NSButton image effects for pressed/disabled
> On Dec 11, 2018, at 5:03 PM, Lars C. Hassing wrote: > > If I assign an image to an NSButton it is displayed with nice pressed and > disabled effects. > > In my custom NSButton, that should display image1+title+image2, I override > drawRect:, but how do I obtain the EXACT SAME system effects for the two > images? Don’t override drawRect; you should use a custom NSButtonCell instead. (In general NSButton is just a wrapper around NSButtonCell.) That itself may solve your problem. If not, you could work around it by creating a single NSImage (at runtime) with the two images and the title in it, and just setting that as the button’s image. —Jens ___ 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Custom NSButton image effects for pressed/disabled
The button should look like +---+ +---+ | 1 | Title | 2 | +---+ +—+ (try using Courier for the ASCII art) I am looking for system functions to produce the SAME look and feel as Cocoa controls. Motif, Windows and Carbon all have system functions to draw control parts in various states to help developers achieve a consistent look and feel, why wouldn’t Cocoa be interested in supporting that? /Lars > Den 12. dec. 2018 kl. 02.03 skrev Lars C. Hassing : > > If I assign an image to an NSButton it is displayed with nice pressed and > disabled effects. > > In my custom NSButton, that should display image1+title+image2, I override > drawRect:, but how do I obtain the EXACT SAME system effects for the two > images? > > I plan to use NSImage drawInRect:fromRect:operation:fraction:, it would be > nice if it had an pressed/disabled/effect argument… > /Lars > ___ 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com