Re: How to detect a single mouse click on a cell in a TableView?
Re: How to detect a single mouse click on a cell in a TableView?
- Subject: Re: How to detect a single mouse click on a cell in a TableView?
- From: Christopher Holland <email@hidden>
- Date: Thu, 11 Apr 2002 09:48:13 -0500
I've used the code in one of my applications that I'm writing right now.
I'll just paste in the handling method here...that should be able to get
you started. As far as getting the mouse coords to figure out which
one...hmmm, I'll have to give that more thought. I'd probably just have
to play around with it a bit to figure it out. Maybe once you get this
working the answer will jump out at you. :)
I'm using the code below to enable/disable three different controls
(think Photoshop's Layers Palette). Some code has been taken out to make
the example cleaner.
You might check out NSResponder for the mouse coordinates and the events
for figuring out between your TextField and Button. NSTableView inherits
from NSResponder (by way of NSControl and NSView).
- (void) handleClickOnTableItem:(id)sender
{
int row = [[self objectTable] clickedRow];
int column = [[self objectTable] clickedColumn];
if (row == -1)
{
// The user clicked away from an item to "deselect" all.
[[self deleteObjectButton] setEnabled:NO];
[[self objectOpacitySlider] setEnabled:NO];
[[self objectOpacityTextField] setEnabled:NO];
}
else
{
// User selected a row in the table
[[self deleteObjectButton] setEnabled:YES];
[[self objectOpacitySlider] setEnabled:YES];
[[self objectOpacityTextField] setEnabled:YES];
}
}
}
On Thursday, April 11, 2002, at 08:28 AM, Gore wrote:
On Thursday, April 11, 2002, at 04:18 , Christopher Holland wrote:
Try this when you setup the table....
[theTable setAction:@selector(handleClickOnTableItem:)];
Then, if you need to, you can do a check to find out which column and
row was clicked in your own handleClickOnTableItem method.
I have the same problem, but how do I get info on what table and row it
was clicked on and how do I get the mouse cordinates so that I know
what part of the cell it was clicked on, because I have a cell that is
both a checkbox and a textfield and need to know which was clicked.
thanks
/Gore
Chris
On Thursday, April 11, 2002, at 05:35 AM, Nicola Vitacolonna wrote:
I have a TableView and I want to toggle a string (say On/Off) in a
cell
of a specific column of the table when the user clicks ot it. I cannot
figure out how to do that... The cell is otherwise uneditable.
I was able to do two similar things, but both have problems:
1) In IB I made the column editable, and then I implemented the
delegate method tableView:shouldEditTableColumn:row: in order to do my
stuff when the user double-clicks on a cell. This is not exactly
what I
wanted (I'd rather like a *single* click fire the action), but what's
worse is that the delegate is called also when the user moves to that
cell with the tab key.
2) I also tried to make the column uneditable in IB and implement
table:didClickTableColumn:, but this is called when the user
double-clicks on the header too, which I definitely don't want to
happen.
I'm sure I'm missing some point... Any hint?
Thanks in advance!
Nicola
_________________________________
Christopher Holland email@hidden
Concept House http://www.concepthouse.com/
_______________________________________________
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.
_______________________________________________
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.