0

I have two NSTableViews. On double clicking on the tableview1 the contents of the tableview1 will be placed in tableview2. I would like to edit the new cell in the tableview2. Tried the following method.

- (void)editColumn:(NSInteger)columnIndex row:(NSInteger)rowIndex withEvent:(NSEvent *)theEvent select:(BOOL)flag

This does not make the tableview2 as firstResponder. The cursor is not in the new cell. I would like to have the cursor in the new cell and start editing the cell. Please give me some pointers to accomplish this. Thanks in advance.

How to bring the cursor in the cell of NSTableView?

Ram
  • 1,872
  • 5
  • 31
  • 54

2 Answers2

1

When the editing started ,fieldEditor comes into picture thats why not able to set the firstResponder.

Implemented the textDidEndEditing delegate of the tableView. It solved the isssue.

Ram
  • 1,872
  • 5
  • 31
  • 54
0

If you are using a NSArrayController to hold the data of your tables, you could override rearrangeObjects:

- (void)rearrangeObjects {
    [super rearrangeObjects];
    [tableView editColumn:0 row:[self selectionIndex] withEvent:nil select:YES];
}

An additional advantage is that this method also seems to scroll the table down to the newly inserted row.

Fnord23
  • 325
  • 2
  • 18
  • of course, in above example, `tableView` is declared as an IBOutlet in the array controller's interface. Drag an array controller in the Interface Builder, set it's class to your subclass of `NSArrayController`, and ctrl-drag from the array controller to the table view to connect the outlet. – Fnord23 Apr 05 '12 at 18:24