(I thought I'd try this again on a weekday.)
I have a window containing an NSTableView. I have a controller object
set as delegate for the table view, but have not subclassed the table
view.
The following applies to the IBAction method that is called whenever
the table is clicked.
I look at a BOOL to decide whether to keep the user from editing
cells
in the table view. However, the cell content needs to remain
selectable for copying or for dragging to other windows.
I can't use -tableView:shouldEditTableColumn:row:, because returning
NO to that apparently prevents cell selection as well as editing.
NSTableColumn -setEditable: causes the same problem.
As this is only called after the table view field editor has become
the first responder, I use the following line to get the current
cell text:
NSTextView *textView = (NSTextView *)[[editorWindowController
window] firstResponder];
Then, if required by my BOOL, I say:
[textView setEditable:NO];
This works just fine if the user single-clicks in a cell. The cell
becomes active, but the text is not automatically selected. The text
is selectable, so it can be copied or dragged, but is not editable,
so it can't be changed.
The problem arises when the user double-clicks in a cell. The cell
content is selected automatically and is editable. (This is not
disastrous, because the document associated with the table view
cannot be saved, but it's still misleading and potentially confusing
to the user.)
Just hacking around, I've also tried adding the following lines,
which don't seem to have any effect, either:
[tableView setIgnoresMultiClick:YES];
[tableView setDoubleAction:nil];
In this same action method, I also set a link attribute if the cell
contains a URL. This works as expected when I single-click; the URL
text becomes blue and underlined. When I double-click a cell that
contains a URL, however, I can see the text going blue and underlined
while the background remains white, but then the text goes plain
again and becomes selected. So, it appears that the double-click is
causing something to happen following my action method, which is
undoing my attempts to make the cell uneditable--and redrawing the
cell in the process.
How do I prevent this? Do I have to subclass my NSTableView? If so,
in which method would I do it? -doubleAction: is called "when the
user double-clicks a column header or an uneditable cell", and my
cells are not technically "uneditable"--or are they? I think I'm
beginning to get confused...
What have I missed in all this mess?