Getting user's input from an NSOutlineView
Getting user's input from an NSOutlineView
- Subject: Getting user's input from an NSOutlineView
- From: Jerry Krinock <email@hidden>
- Date: Tue, 19 Apr 2005 21:10:20 -0700
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
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden