Re: Button confusion
Re: Button confusion
- Subject: Re: Button confusion
- From: Jeremy Dronfield <email@hidden>
- Date: Tue, 1 Jun 2004 21:20:54 +0100
On 1 Jun 2004, at 6:14 pm, Darrin Cardani wrote:
I'm confused about how buttons with custom icons are supposed to work.
I have several buttons in a window. They are square buttons without a
border, and they have an icon and an alternate icon. They are set to
"Momentary Change". Initially, the buttons are disabled, but through
user actions can become enabled and disabled again.
When the window is first displayed, the disabled buttons are showing
their alternate icon. This is the icon I want displayed when the
button is pressed, not when it is disabled. And once they are enabled,
they work the way I expect. They show their regular icon, until the
user presses them, then they show their alternate, until the user lets
up, at which time they show their regular icon again. Once they are
disabled again, they appear not to be disabled at all, but simply
don't react to presses.
Using borderless buttons with custom icons is tricky, if you want to
get a really pro look in your UI. To get the best results, it's best to
cut out the default Cocoa button display for the disabled state. For
example, look at the back-and-forward navigation buttons in Safari or
the Finder: they use three custom images: one "normal", one for
"pressed" and one "disabled". I've implemented the same thing in an
application of mine. I found that, to achieve the neat-n-tidy display
characteristics of the Safari buttons, I had to avoid using
-setEnabled: to switch the buttons off and on. When disabling them, I
send them -setTarget:nil and -setImage:disabledImage AND
-setAlternateImage:disabledImage. Then, to re-enable them,
-setTarget:self (or whatever), plus -setImage:normalImage and
-setAlternateImage:pressedImage.
Hope this helps. Regards,
-Jeremy
===================================
SkoobySoft, home of viJournal
email: email@hidden or visit:
http://freespace.virgin.net/jeremy.dronfield/skoobysoft.html
===================================
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.