An improved version of NodeOutlineGroup

This is the second post of my little series about a fine-tuned version of my OutlinePicker. Today, I’d like to propose an improved version of the already presented NodeOutlineGroup. As stated here the NodeOutlineGroup gives you control whether the disclosure group should be collapsed or expanded on show up of the outline group. I want to use that for my hierarchical picker. But on start of my picker the pre-selected node might be deep in the tree instead of being one of the root nodes.

So, if I set up the picker with all nodes collapsed the pre-selected node would not be visible immediately and the user might search for it for quite a long time. On the other hand, if I expand all nodes it might be quite a big tree to display on startup. The ideal solution would be that all nodes are collapsed except to those ones which have the selected node as a child or grand child.

To accomplish that the NodeOutlineGroup needs to get an array of those nodes which should be expanded on startup. This is my proposal for the improved version of NodeOutlineGroup:

Line 7 declares the new optional input parameter of the list of node to expand. And lines 27-31 check if the current node should be expanded and override the default behaviour of expansion. That’s it. Now, we only have to generate this array of nodes to expand but we’ll keep that for the next post.

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert