how do I detect a click in a tableView cell?
how do I detect a click in a tableView cell?
- Subject: how do I detect a click in a tableView cell?
- From: Denis Stanton <email@hidden>
- Date: Mon, 22 Mar 2004 10:17:46 +1200
I hope someone can give me a nudge in the right direction here.
I have a tableView in which one of the two columns contains a row of
coloured rectangles of different sizes. The application is for
calendar scheduling and the rectangles represent blocks of days along
the x axis.
I want to be able to click on one of these blocks to select a calendar
event, so I need to detect mouse clicks within a cell in a column of a
tableView. I will then compare the location to the list of rectangles
drawn into that cell and figure out which one was selected.
I'm having trouble detecting the click. I thought I could just
subclass the method
- (void)mouseDown:(NSEvent *)theEvent;
and add my rectangle-matching code, but I don't seem to be putting my
mouseDown method into the right place.
In order to draw the rectangles into the cell I made a class ChartCell
: NSTextFieldCell. And then subclassed
(void)drawInteriorWithFrame: (NSRect)cellFrame inView: (NSView
*)controlView;
I tell the tableView to use my modified version of NSTextFieldCell in
the awakeFromNib
NSTableColumn *tableColumn = [[chart tableColumns] objectAtIndex : 1];
NSCell *newCell = [[ChartCell new] autorelease];
[tableColumn setDataCell: newCell];
I tried putting my custom mouseDown method into my custom ChartCell
class, expecting it to get called when I clicked in one of these cells.
This doesn't work and I can see now that Interface Builder has no way
of knowing that clicks on the tableView should be passed to my
ChartCell class, but I'm getting confused and I can't think where to
put my mouseDown method.
Denis Stanton
email@hidden
Home: +64 9 533 0391
mobile: +64 21 1433622
_______________________________________________
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.