Re: NSButtonCell Ignores Button Type
Re: NSButtonCell Ignores Button Type
- Subject: Re: NSButtonCell Ignores Button Type
- From: Ricky Sharp <email@hidden>
- Date: Tue, 29 Mar 2005 14:31:55 -0600
On Mar 29, 2005, at 2:02 PM, Ricky Sharp wrote:
On Mar 29, 2005, at 1:44 PM, Seth Willits wrote:
Another problem I'm having is figuring out which button is actually
clicked. Not selected (since there is no selection when in
NSHighlightModeMatrix), but actually clicked. I thought something
like
- (void)mouseUp:(NSEvent *)event
{
BOOL cellWasHit;
NSPoint point;
point = [self convertPoint:[event locationInWindow] fromView:nil];
cellWasHit = [self getRow:&lastRow column:&lastColumn
forPoint:point];
if (!cellWasHit) {
lastRow = lastColumn = -1;
}
[super mouseUp:event];
}
... would work, but mouseUp is never called.
This is probably due to a local (local to the matrix) code to handle
mouse tracking.
Anyhow, how about setting the tag on each of your button cells (Tag
field in the cell's inspector in IB or programatically with setTag:)
Then, assign a common action to all your cells (e.g.
matrixCellClicked:)
It would be implemented like:
- (IBAction)matrixCellClicked:(id)sender
{
NSLog (@"You clicked on cell %d", [sender tag]);
}
You know, this may not work out. When originally writing my custom
widgets, I was subclassing NSButtonCell and NSButton. But that caused
much grief when working with NSMatrix.
I've found that if you want ultimate control over tracking behavior,
firing actions, etc. in a matrix, you may be better off subclassing
NSMatrix and handling tracking yourself. I've done this to form custom
radio button groups (NSMatrix subclass holding NSActionCell subclass
cells).
I seem to remember that the above code may not work since the sender of
the action would not be the cell (as you'd expect), but the matrix
itself. And since you only have one matrix, [sender tag] would always
return the same value; the tag value of the matrix.
___________________________________________________________
Ricky A. Sharp mailto:email@hidden
Instant Interactive(tm) http://www.instantinteractive.com
_______________________________________________
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