Detecting editing in NSTableView cells?
Detecting editing in NSTableView cells?
- Subject: Detecting editing in NSTableView cells?
- From: Matt Ridley <email@hidden>
- Date: Sun, 17 Jun 2001 13:59:07 +0100
Hi folks,
I have an NSTableView which contains standard NSTextFieldCells. I have my
table delegate and datasource and such all set up and working fine, allowing
the user to edit the table's contents.
However, I need to be able to detect when a user has finished editing a cell
(signified by the user either pressing return or tab or shift-tab to move to
another cell, or clicking into another row or cell), and do some processing
to decide whether to "allow" their changes. Essentially, I need to intercept
the process between them finishing editing the cell and the table data
source performing setObjectValue:forTableColumn:row:.
From reading the documentation, I believe I can do this by implementing this
method of NSTableView:
- (BOOL)textShouldEndEditing:(NSText *)textObject
I have three questions regarding this:
1. Is this the correct course of action?
2. How do I ask textObject which column and row of the table it's in? Or
should I just use selectedColumn and selectedRow?
3. I presume that my table delegate is the correct place to implement the
textShouldEndEditing method? The method is listed under "Text delegate
methods" in NSTableView's documentation, and I'm not sure whether it will be
automatically found in my table delegate, or whether I need to specify
something in Interface Builder.
Thanks for any help. :-)
--
// Matt
- (void)visitMySite {
[[NSWorkspace sharedWorkspace] openURL:
[NSURL URLWithString:@"
http://www.scotlandsoftware.com/"]];
}