Search code examples
cocoaosx-mavericksnstableview

How to deselect the contents of a table cell when I move to it?


I am successfully using

[myTable editColumn:aColumn row:aRow withEvent:nil select:NO];

to move to a different table cell and start editing it.

The problem is that the text is always selected, irrespective of the select: parameter. If the user isn't careful the pre-existing text is lost on the next key press. No problem navigating cells with the mouse.

The table is view-based, the cells are populated with a vanilla NSTextField, the content is bound via an NSArrayController to a local array, not Core Data.


Solution

  • Make this your next statement:

    [_window.firstResponder performSelector:@selector(moveRight:)];
    

    _window is your controller's window or whatever. Use moveLeft: if you prefer.