Re: NSButtonCell Ignores Button Type -- A Discovery and Annoyance
Re: NSButtonCell Ignores Button Type -- A Discovery and Annoyance
- Subject: Re: NSButtonCell Ignores Button Type -- A Discovery and Annoyance
- From: Seth Willits <email@hidden>
- Date: Tue, 29 Mar 2005 16:40:37 -0800
I have a bunch of NSButtonCells in an NSMatrix and no matter what I
do, the cells toggle their states when clicked on, despite their
button types being set to NSMomentaryPushInButton. I have looked at
this for an hour and tried a million things, but I can't figure out
why this is happening. I can setup a small test matrix and they work
just fine, but mine refuses to.
A small discovery on this:
I have a custom NSButtonCell subclass which merely draws a customized
button. The code for this is nothing fancy at all:
- (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView
{
// Draw Button
if ([self isHighlighted] || [self state] == NSOnState) {
... Draw Highlighted
} else if ([self isEnabled] == NO) {
... Draw Disabled
} else {
... Draw Normal
}
// Draw Text
...
}
When I use my custom cell, I get the toggling behavior like I said
above. However if I use a normal NSButtonCell (no custom drawing), it
draws and behaves as a normal push button. I add on with a category to
NSButtonCell and put a break point in the setState method, and have
found out that the NSButtonCell code simply ignores what the state is
when drawing, and only uses [self isHighlighted]. Now, I would do this
if I could, except that I elsewhere, I *do* want my cells to use a
toggling behavior. I *thought* NSMatrix took care of this with the
different matrix modes, but it's obvious now that it does not.
So things I don't understand about NSMatrix are:
a) How can NSMatrix have all of the selection methods and such for the
NSCells is contains, if it has no affect on the visual appearance and
behavior of those cells? How are *we* supposed to do that, if in fact
NSMatrix doesn't?
b) Why is the sender of cell actions the NSMatrix instead of the cell?
How are *we* supposed to determine which cell of a NSMatrix was clicked
when this is true?
c) How can a NSButtonCell with it's button type clearly set to
NSMomentaryPushInButton actually toggle in state? How are *we* supposed
to stop that?
Seth Willits
------------------------------------------------------------------------
---
President and Head Developer of Freak Software - http://www.freaksw.com
REALbasic Guru at ResExcellence - http://www.resexcellence.com/realbasic
"Yesterday we obeyed kings and bent our necks before emperors. But
today we kneel only to truth, follow only beauty, and obey only love."
-- Kahlil Gibran
------------------------------------------------------------------------
---
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden