Reputation: 5757
I have an NSOutlineView that acts like a source list, but does not use the actual source list highlighting style. (Imagine the sidebar in the Finder.)
This outlineView has only two levels: 1) "groups" and 2) "subitems". There is no additional nesting --- again, just like the source list in the Finder.
The top-level "group" rows in my OutlineView are NSTableCellViews
with a single NSTextField
. I would like my users to be able to edit the text in this textField (to rename the group) WITHOUT allowing them to select the entire group row in the OutlineView.
So far, I've not found a way to do this. If I prevent selection of group rows in my delegate for the OutlineView, it is not possible to edit the textfield. When I allow selection of the group rows, then I can get the textfield to edit just like any other.
Short of subclassing things and handling mouse events myself, is there a simple way to do this? Must a row in an NSTableView always be selected before textFields in that row can be edited?
Upvotes: 1
Views: 280
Reputation: 90581
I think it will work to use a custom subclass of NSOutlineView
in which you override -validateProposedFirstResponder:forEvent:
to return true if the proposed first responder is in a group row. Return whatever super returns for any other proposed first responder.
You can determine which row the proposed first responder is in by calling -rowForView:
.
See this blog post from the Apple engineer who wrote the view-based table view stuff.
Upvotes: 1