• 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
Re: What is the best way to use NSOutlineView without NSTreeController?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: What is the best way to use NSOutlineView without NSTreeController?


  • Subject: Re: What is the best way to use NSOutlineView without NSTreeController?
  • From: Andrei Tchijov <email@hidden>
  • Date: Fri, 2 Dec 2005 18:38:09 -0500

It looks like I came up with better solution. Instead of playing with "willChange/didChange" I have created dummy method "setCurrentlySelectedOutlineItem:" and calling it in "outlineViewSelectionDidChange". It works now the way I want it. Ok, almost the way I wan it to work. When I am selecting an item from NSOutlineView first time, I am getting "removeObserver:forKeyPath: was sent to an object that has no observers" exception again. I deal with it, by re-implementing this method in my class ( luckily all items in OutlineView are subclasses of the same class ). In my implementation I am just catching this exception and ignoring it. I can not say that I like it very much, but I can not see any way to test is particular object has an observer registered for particular path.


On Dec 2, 2005, at 5:34 PM, glenn andreas wrote:


On Dec 2, 2005, at 4:14 PM, Andrei Tchijov wrote:

Glenn,
Thanks for reply, but I already have tried this kind of approach and it looks like it does not work. Problem number one, when you are switching from "none selected" to "one selected", "willChangeValueForKey" generate exception ( removeObserver:forKeyPath: was sent to an object that has no observers ). I can solve this by doing "willChangeValueForKey" in selectionShouldChangeInOutlineView only if something was selected. Problem number 2 is that it still does not work. When I type in text field (which is bound to path ), proper object gets updated, but when I change selection, text field does not get updated.

If I understand this correctly, problem number 2 is related to the concept of the "field editor" and when changing selection you'll want to make sure to commit the current edit select (or cancel the selection if the commit doesn't work - for example, if the field has a number with a min and max value, and the user typed something beyond that). The NSTreeController automatically handles that for you (which is why setSelectionIndexPath returns a BOOL to indicate if it was successful).

Look into NSEditorRegistration informal protocol and NSEditor informal protocol (especially "commitEditing").

(Of course, this only applies if your detail view includes things like edit fields - things like popup menus, sliders, checkboxes, etc... all happen without any need to be committed).


Glenn Andreas email@hidden
<http://www.gandreas.com/> wicked fun!
quadrium | build, mutate, evolve | images, textures, backgrounds, art


_______________________________________________
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
References: 
 >What is the best way to use NSOutlineView without NSTreeController? (From: Andrei Tchijov <email@hidden>)
 >Re: What is the best way to use NSOutlineView without NSTreeController? (From: glenn andreas <email@hidden>)
 >Re: What is the best way to use NSOutlineView without NSTreeController? (From: Andrei Tchijov <email@hidden>)
 >Re: What is the best way to use NSOutlineView without NSTreeController? (From: glenn andreas <email@hidden>)

  • Prev by Date: Re: Is Apple's singleton sample code correct?
  • Next by Date: Re: Is Apple's singleton sample code correct?
  • Previous by thread: Re: What is the best way to use NSOutlineView without NSTreeController?
  • Next by thread: No NSMovieView in Graphics Views palette...
  • Index(es):
    • Date
    • Thread