Re: NSButtonCell Ignores Button Type -- Hacked Solution
Re: NSButtonCell Ignores Button Type -- Hacked Solution
- Subject: Re: NSButtonCell Ignores Button Type -- Hacked Solution
- From: Seth Willits <email@hidden>
- Date: Tue, 29 Mar 2005 17:23:24 -0800
Sorry for the noise, but I've hacked my way into a solution that works
for me that I thought I'd shared, and hopefully someone will think it's
ugly and post a better one.
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?
In a NSButtonCell subclass, I have:
- (void)setState:(int)state
{
MyCustomMatrix * matrix = (MyCustomMatrix *)[self controlView];
if ([matrix inSelectionMode]) {
[super setState:state];
return;
}
[super setState:0];
}
[matrix inSelectionMode] is a boolean dictating whether a cell can be
selected or not. This probably should be changed to work off of the
button type, but it would have required more code in my specific case,
so I did it this way.
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?
I still have no idea why, but here's the solution. In an NSCell
subclass:
- (void)_sendActionFrom:(id)sender
{
[[NSApplication sharedApplication] sendAction:[self action] to:[self
target] from:self];
}
*This* code requires that you set the action for each cell (they can be
the same, no worries there), though it could be written differently.
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?
I have no idea why this is, but see the solution to a.
Seth Willits
------------------------------------------------------------------------
---
President and Head Developer of Freak Software - http://www.freaksw.com
REALbasic Guru at ResExcellence - http://www.resexcellence.com/realbasic
"Your friend is the person who knows all about you and still likes you."
-- Elbert Green Hubbard
------------------------------------------------------------------------
---
_______________________________________________
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