Re: Sorting a TableView in tableView:setObjectValue:forTableColumn:row:
Re: Sorting a TableView in tableView:setObjectValue:forTableColumn:row:
- Subject: Re: Sorting a TableView in tableView:setObjectValue:forTableColumn:row:
- From: Andreas Mayer <email@hidden>
- Date: Sat, 12 Oct 2002 06:16:36 +0200
Am Samstag, 12.10.02 um 04:44 Uhr schrieb Ondra Cada:
Never mind that, it it does not, just postpone it to the end of the
event,
Nice idea. But that only kind-of works.
Normally the next (or previous or whatever) cell would be selected for
editing. This method selects the current row regardless of the way the
editing ended and I do not know what cell to select for editing either.
I would have to look at what textDidEndEditing: changed. I think that's
even more complicated than doing it myself in the first place.
So that's what I did now: I replaced the NSTableView with my own
subclass and overwrote textDidEndEditing:
- (void)textDidEndEditing:(NSNotification *)aNotification
{
int column;
int row;
NSString *newValue;
column = [self editedColumn];
newValue = [[[[aNotification object] string] copy] autorelease];
[super textDidEndEditing:aNotification];
if (column == [self columnWithIdentifier:@"VarName"]) { // only
affects column "VarName"
row = [(MyTableViewDataSource *)[self dataSource] tableView:self
rowForKey:newValue]; // get new row
switch ([[[aNotification userInfo] objectForKey:@"NSTextMovement"]
intValue]) {
case NSReturnTextMovement: // return
{
row++;
if (row >= [self numberOfRows])
row = 0;
break;
}
case NSBacktabTextMovement: // shift tab
{
if (column == 0) {
row--;
if (row < 0)
row = [self numberOfRows]-1;
column = [self numberOfColumns]-1;
} else {
column--;
}
break;
}
//case NSTabTextMovement: // tab
default:
{
if (column == [self numberOfColumns]-1) {
row++;
if (row >= [self numberOfRows])
row = 0;
column = 0;
} else {
column++;
}
}
} // switch
[self selectRow:row byExtendingSelection:NO];
[self editColumn:column row:row withEvent:nil select:YES];
}
}
This seems to work right now. But it may break in the future if
NSTableView's textDidEndEditing: changes. :-/
A possible solution might be, if textDidEndEditing: based it's
calculation of which cell to edit next, on the row selected *after*
sending tableView:setObjectValue:forTableColumn:row: to the delegate.
bye. Andreas.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.