• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Getting user's input from an NSOutlineView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: Getting user's input from an NSOutlineView
      • From: Jerry Krinock <email@hidden>
  • Prev by Date: RE: Category or Protocol? (sidetrack)
  • Next by Date: RE: Category or Protocol? (sidetrack)
  • Previous by thread: Re: Open with menu
  • Next by thread: Re: Getting user's input from an NSOutlineView
  • Index(es):
    • Date
    • Thread