Search code examples
macoscocoanstextfieldnsoutlineview

How to edit text field in NSOutlineView on a double click?


In my OSX app I have a view-based NSOutlineView. Its rows have text fields that I want to be edited on a double-click.

For some reason by default text field would go to the edit mode on a right-click. So I want to change it as well as be able to catch the event when the edit is finished to be able to get the new value.

Before I had this NSOutlineView cell-based and it was all working properly and I was able to catch the new value in:

- (void)outlineView:(NSOutlineView *)outlineView setObjectValue:(id)object forTableColumn:(NSTableColumn *)tableColumn byItem:(id)item

After I switched to view-based outline view text field would go to the edit mode on a right-click and the method above is not getting called.

Any kind of help is highly appreciated.


Solution

  • Just found the post that explains how to do the double-click business:

    Respond to mouse events in text field in view-based table view

    Although, I still need to figure out how to get the new value!

    Found the second part of the question here:

    Delegate events for NSTextField in a view-based NSOutlineView?