…maybe it’s not a real table view question, but more a text view one…
I have a table view connected to an array controller where one of the fields is connected to a text view for editing.
The table view allows to select multiple rows (for other purposes).
The above mentioned editing only makes sense with a single row selected. So how to control the ‘editable’ of the text view based upon the ‘selectedRowIndexes’?
I can’t find any ‘should…’
TIA for any ideas.
You could probably implement the delegate method
-tableViewSelectionDidChange:, and handle it there.
That’s what already is done, but it doesn’t help since it only responses to mouse events.
So something like ‘shift-arrow-down’ is not captured.
Hmm, wouldn’t that contradict the ‘multiple selection allowed’ in this case?
I think I’ve found a way, though it seems to be a strange one.
The text is listed in the table view and for editing in a text view. In the table I put the text into a text field. This can be linked to a ‘textShouldBeginEditing:’.
So with several rows selected this can return ‘false’ (and the text view won’t work) while other things for the selected rows will work.
set idxSet to subsTableView's selectedRowIndexes
set idxCount to (count of idxSet)
if idxCount = 1 then
defaults's setBool:true forKey:"rowTxEditable"
set zRow to subsArrayController's selectedObjects()'s lastObject()
defaults's setBool:false forKey:"rowTxEditable"