Skip navigation.
 
mlRe: NSOutlineViewWill Expand/Collapse notifications
FROM : Corbin Dunn
DATE : Thu Jun 08 19:30:35 2006

On Jun 7, 2006, at 6:34 PM, Ken Victor wrote:

> i'm registered for outline view will expand/collapse notifications. 
> the documentation clearly states that these notifications are sent 
> BEFORE the associated clicked row is expanded/collapsed as follows:
>
> Posted before an item is collapsed (after the user clicks the arrow 
> but before the item is collapsed).
> The notification object is the NSOutlineView object that contains 
> the item about to be collapsed. A collapsed item's children will 
> lose their status as being selected. The userInfo dictionary 
> contains the following information:
>
> and:
>
> Posted before an item is expanded (after the user clicks the arrow 
> but before the item is collapsed).
> The notification object is the outline view that contains an item 
> about to be expanded. The userInfo dictionary contains the following 
> information:
>
> yet, in my notification routine when i checked the state of the item 
> via [NSOutlineView isItemExpanded:] its as if the notification is 
> sent AFTER the item has expanded/collapsed.
>
> is this a known bug? or is this a documentation bug?


Well, to be extra ambiguous, yes and no (to both questions).

The logic is as follows:

The expanded state of the item is set to the new value
The notification is sent.
The logic that adjusts the number of rows happens.

So, in one respect, the expand/collapse hasn't really happened at the 
point of the notification, but asking isItemExpanded: will return the 
correct thing for what is going to happen (but, it really hasn't 
happened yet).

Is this a bug? well, people may depend on it working this way, and in 
some respects it is considered correct.

Is there a different bug on Tiger with regards to this? Yes! 
Unfortunately, the numberOfChildren: datasource method is called 
BEFORE the "willExpand" notification is sent. I definitely see this as 
an error, and this is fixed on Leopard.

thanks,
Corbin

Related mailsAuthorDate
mlNSOutlineViewWill Expand/Collapse notifications Ken Victor Jun 8, 03:34
mlRe: NSOutlineViewWill Expand/Collapse notifications Corbin Dunn Jun 8, 19:30