FROM : Wdyp
DATE : Sat Dec 01 08:03:16 2007
> Subject: Overriding the new inter-cell navigation of NSTableView
>
> Hi!
> In my app I need to be able to have the return, enter or down arrow
> key
> give focus to the cell that is under the current one and begin
> editing,
> to edit sequentially the same attribute of multiple objects.
> What is the best way of doing this?
> Thanks,
> Flofl.
I found that the keyDown: + interpretKeyEvents method wouldn't work
with the NSTextFieldCell so I ended up overriding endEditing: (tv is
an outlet to the parent tableView of the cell):
- (void)endEditing:(NSText *)textObj {
int editedRow = [tv editedRow];
int editedColumn = [tv editedColumn];
int numberOfRows = [tv numberOfRows];
editedRow ++;
editedRow = (editedRow == numberOfRows ? 0 : editedRow); //
Selects the first row when the las one is reached.
[super endEditing:textObj];
// Select the row (needed to avoid an exception to be raised).
[tv selectRow:editedRow byExtendingSelection:NO];
[tv editColumn:editedColumn
row:editedRow
withEvent:nil
select:YES];
}
It works, but is it the best way? It looks more like a workaround than
like the regular way of customizing "the tab-loop behavior"... And
what if I want to take different actions according to the key that
ended the editing?
Flofl.
DATE : Sat Dec 01 08:03:16 2007
> Subject: Overriding the new inter-cell navigation of NSTableView
>
> Hi!
> In my app I need to be able to have the return, enter or down arrow
> key
> give focus to the cell that is under the current one and begin
> editing,
> to edit sequentially the same attribute of multiple objects.
> What is the best way of doing this?
> Thanks,
> Flofl.
I found that the keyDown: + interpretKeyEvents method wouldn't work
with the NSTextFieldCell so I ended up overriding endEditing: (tv is
an outlet to the parent tableView of the cell):
- (void)endEditing:(NSText *)textObj {
int editedRow = [tv editedRow];
int editedColumn = [tv editedColumn];
int numberOfRows = [tv numberOfRows];
editedRow ++;
editedRow = (editedRow == numberOfRows ? 0 : editedRow); //
Selects the first row when the las one is reached.
[super endEditing:textObj];
// Select the row (needed to avoid an exception to be raised).
[tv selectRow:editedRow byExtendingSelection:NO];
[tv editColumn:editedColumn
row:editedRow
withEvent:nil
select:YES];
}
It works, but is it the best way? It looks more like a workaround than
like the regular way of customizing "the tab-loop behavior"... And
what if I want to take different actions according to the key that
ended the editing?
Flofl.
| Related mails | Author | Date |
|---|---|---|
| Wdyp | Nov 30, 20:18 | |
| Wdyp | Dec 1, 08:03 | |
| Corbin Dunn | Dec 3, 21:41 |






Cocoa mail archive

