Autoselect, focus and highlight a new NSOutlineView row
Posted
by
coneybeare
on Stack Overflow
See other posts from Stack Overflow
or by coneybeare
Published on 2011-02-18T22:56:11Z
Indexed on
2011/02/18
23:25 UTC
Read the original article
Hit count: 281
This is probably just lack of experience with the NSOutlineView
but I can't see a way to do this. I have a NSOutlineView
(implemented with the excellent PXSourceList) with an add button that is totally functional in the aspect that I save/write/insert/delete rows correctly. I do not use a NSTreeController
, and I don't use bindings. I add the entity using the following code:
- (void)addEntity:(NSNotification *)notification {
// Create the core data representation, and add it as a child to the parent node
UABaseNode *node = [[UAModelController defaultModelController] createBaseNode];
[sourceList reloadData];
for (int i = 0; i < [sourceList numberOfRows]; i++) {
if (node == [sourceList itemAtRow:i]) {
[sourceList selectRowIndexes:[NSIndexSet indexSetWithIndex:i] byExtendingSelection:NO];
[sourceList editColumn:0 row:i withEvent:nil select:NO];
break;
}
}
}
When the add button is pressed, a new row is inserted like this:
If I click away, then select the row and press enter
to edit it, it now looks like this:
My question is: How can I programmatically get the same state (focus, selected, highlighted) the first time, to make the user experience better?
© Stack Overflow or respective owner