Skip navigation.
 
mlRe: [NSOutlineView] How to know an item is expanded if its parent item is not?
FROM : Stéphane Sudre
DATE : Sun Mar 02 16:23:35 2008

On Mar 2, 2008, at 5:24 AM, Seth Willits wrote:

> On Mar 1, 2008, at 6:01 PM, John Stiles wrote:
>

>> Unless Stephane plans on manually tracking the expanded items 
>> himself, I don't see how this answers his original question

>
>
> That's what you have to do. I use these notifications to save which 
> items are expanded as part of my documents' data. It's not 
> particularly hard since at the very least, all you do is just keep 
> an array of expanded items.


It might not be hard but it does not work.

Let's say I have the following hierarchy:

  Group --+-- Group 1
          |
          +-- Group 2
          |
          +-- Group 3


First, I don't implement notifications:

1. I disclose Group with the mouse
2. I disclose Group 1, Group 2, Group 3 with the mouse
3. I close Group
4. I disclose Group

=> Group 1, Group 2 and Group 3 are disclosed.

Then I implement outlineViewItemWillExpand: and 
outlineViewItemWillCollapse: notifications and see what happens when 
I follow the same procedure:

1. I disclose Group with the mouse

=> I receive a outlineViewItemWillExpand: notification for Group

2. I disclose Group 1, Group 2, Group 3 with the mouse

=> I receive outlineViewItemWillExpand: notifications for Group 1, 
Group 2 and Group 3

3. I close Group

=> I receive a outlineViewItemWillCollapse: notification for Group 
AND outlineViewItemWillCollapse: notifications for Group 1, Group 2 
and Group 3

4. I disclose Group

=> I receive a outlineViewItemWillExpand: notification for Group AND 
outlineViewItemWillExpand: notifications for Group 1, Group 2 and 
Group 3


So, apparently, it's just not that easy. And one thing to take into 
account in the array is the order in which items are listed because 
you need to have the correct order, otherwise the parent of an item 
may be processed after the item itself - which is not good -.

Maybe a solution could be to check if one of the parents for a group 
is collapsed or not before taking into account the notification...

Anyway, wouldn't it be much easier if the cache used by NSOutlineView 
(since it remembers which children were to be expanded) was accessible.

Related mailsAuthorDate
ml[NSOutlineView] How to know an item is expanded if its parent item is not? Stéphane Sudre Mar 2, 00:02
mlRe: [NSOutlineView] How to know an item is expanded if its parent item is not? j o a r Mar 2, 00:42
mlRe: [NSOutlineView] How to know an item is expanded if its parent item is not? John Stiles Mar 2, 03:01
mlRe: [NSOutlineView] How to know an item is expanded if its parent item is not? Seth Willits Mar 2, 05:24
mlRe: [NSOutlineView] How to know an item is expanded if its parent item is not? Stéphane Sudre Mar 2, 16:23
mlRe: [NSOutlineView] How to know an item is expanded if its parent item is not? Jonathan Dann Mar 2, 17:50