Cells within cells and mouse tracking
Cells within cells and mouse tracking
- Subject: Cells within cells and mouse tracking
- From: Pete Yandell <email@hidden>
- Date: Sun, 20 Jul 2003 00:25:34 +1000
What I'm Trying To Do
I'm creating a subclass of NSCell, called MyCell, that contains several
other cells. This is so that I can have a single cell in an
NSOutlineView contain several controls along with some text.
The Problem
When an NSButtonCell which is set up as a checkbox and contained in
MyCell is clicked, the checkbox's rectangle is not darkened while the
mouse is down like normal checkboxes. The click is handled and tracked
correctly and the checkbox is toggled when the mouse is released, but
the immediate user feedback does not happen while the mouse is being
tracked.
Any idea what I'm missing? I've scoured the documentation and can't
find anything that talks about drawing and highlighting during mouse
tracking in cells.
A simple version of MyCell that contains only an NSButtonCell and
exhibits the described problem is given below.
Pete Yandell
http://pete.yandell.com/
@interface MyCell : NSCell {
NSButtonCell* buttonCell;
}
- (id)init;
- (id)copyWithZone:(NSZone*)zone;
- (void)dealloc;
- (void)drawWithFrame:(NSRect)cellFrame inView:(NSView*)controlView;
- (BOOL)trackMouse:(NSEvent*)theEvent inRect:(NSRect)cellFrame
ofView:(NSView*)controlView untilMouseUp:(BOOL)untilMouseUp;
@end
@implementation MyCell
- (id)init
{
self = [super initTextCell:@""];
if (self != nil) {
buttonCell = [[NSButtonCell alloc] init];
[buttonCell setButtonType:NSSwitchButton];
[buttonCell setTitle:@""];
}
return self;
}
- (id)copyWithZone:(NSZone*)zone
{
MyCell* cell = [super copyWithZone:zone];
cell->buttonCell = [buttonCell retain];
return cell;
}
- (void)dealloc
{
[buttonCell release];
[super dealloc];
}
- (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView
{
[buttonCell drawWithFrame:cellFrame inView:controlView];
}
- (BOOL)trackMouse:(NSEvent*)theEvent inRect:(NSRect)cellFrame
ofView:(NSView*)controlView untilMouseUp:(BOOL)untilMouseUp
{
return [buttonCell trackMouse:theEvent inRect:cellFrame
ofView:controlView untilMouseUp:untilMouseUp];
}
@end
_______________________________________________
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.