Skip navigation.
 
mlGetting user's input from an NSOutlineView
FROM : Jerry Krinock
DATE : Wed Apr 20 06:10:20 2005

I did what I thought was the hard part, displaying my NSDictionary/tree in
an NSOutlineView, by reading Apple docs, Cocoabuilder and Hilleglass.  It
all displays very cool.  This outline displays ordinary NSStrings.

But now I'm stumped on the easy part, which is to get user's editing input
out of the NSOutlineView.

Since NSOutlineView is a subclass of NSTableView, I tried to implement the
same delegate method which works for NSTableViews,
tableView:setObjectValue:forTableColumn:row:.  But this method never gets
called, and I never even get asked if I respond to it.  No good.

Instead, I saw that I am asked if I respond to various NSControl delegate
methods.  After some tinkering, I found that I am able to get the text and
the target object by implementing the following delegate method:

- (BOOL)control:(NSControl *)control isValidObject:(id)anObject
{
    NSOutlineView* theView = [myController myOutlineView] ;
    int iRow = [theView selectedRow] ;
    int iCol = [theView selectedColumn] ;
    NSMutableDictionary* targetObject = [theView itemAtRow:iRow] ;
    ... insert code here to copy desired data from anObject into
          the target key of targetObject
    return YES ;
}

I have two problems with this.

First of all, it looks like a kludge and I find it hard to believe that this
is the correct approach.

Second, my NSOutlineView seems to select entire rows at a time, and
therefore -selectedColumn returns iCol=-1, indicaing no column is selected,
so I don't know which column the user entered the text in, which I need to
identify the target key.

Please tell me what I'm doing wrong.

Thanks,

Jerry Krinock

Related mailsAuthorDate
mlGetting user's input from an NSOutlineView Jerry Krinock Apr 20, 06:10
mlRe: Getting user's input from an NSOutlineView Jerry Krinock Apr 20, 14:08
mlRe: Getting user's input from an NSOutlineView Johnny Deadman Apr 20, 14:35
mlRe: Getting user's input from an NSOutlineView Matt Neuburg Apr 20, 16:38