Scrolling for a CollapsingRecordNode

I am trying to create a component in GO that simulates a .Net TreeView.

I tried to use the idea from the sample for the ScrollingMultiTextNode where we change the value of the GoGroupList.TopIndex (CollapsingRecordNodeItemList in this case) from -1 to 0 and increment/decrement it based on the ‘scrollbutton’ clicks.

I am running into a weird issue. When I set the TopIndex to 0, the first item in the list shown at the bottom. It works ok, when the TopIndex is greater than 0.

CollapsingRecordNodeItemList was written with collapsing in mind, not scrolling. I played with this a while back and didn’t have much success. As I recall, the height of items scrolling off the top can be variable if you just change TopIndex on the top level ListGroup.

Well, I tried with a flat tree (GoListGroup) hosted inside a GoNode. When I set the TopIndex to 0, the first item shows towards the end of the container GoNode. Whereas, if I leave the TopIndex as -1, it fills the container properly. Any clue as why it is happening ?

No, I don’t even have a theory on how that could happen.



It did occur to me that I did work on another approach (to scroll an arbitrarily complex node) that had some promise, but I don’t have it in a package with a bow on it.



It’s late here. Reply to the email I sent you earlier, and we can discuss that tomorrow.

As I said in my email to you, I’m not sure my other approach will work…



but… I went back and just played with CRN and TopIndex, and have an answer to your first question… the first item isn’t showing at the bottom of the list when TopIndex is 0. The dark blue is the background of the whole node. When you scroll the title (^ Collapsing Record) off the top, the one line you see at the bottom is the background showing through. You need to disable scrolling in the situation where scrolling up would make the visible items less that the height of the node.

Disabling worked! Also, it seems like the top visible index should be 1. As in, the top item is associated with index 1.

Continuing the discussion on scrolling for the CRN –

My understanding is that a GoListGroup is supposed to stack the GoObjects inside it from top to bottom (in case of vertical alignment). So, if I place this GoListGroup inside a GoNode and set the TopIndex to 0, the first item in the GoListGroup is supposed to show up starting at the top left corner of the host GoNode and subsequent items underneath it, till it exausts the available space. Now, if the items inside the top GoListGroup are GoListGroups themselves, what happens ?

GoListGroup handles the way it computes Bounds differently if TopIndex is -1 or >= 0.



If it is -1, it assumes there is no scrolling, and it computes the height (or width, depending on Orientation) to be the sum of the heights (or widths) of all the Visible children.



If TopIndex is >=0, it assumes something else is setting the height (or width) of the GoListGroup, and it manages the Visibility of the subitems so they fit (where TopIndex is the first Visible = true).



GoListGroup doesn’t care what the GoObjects are that are the children, so they can be complex, like other GoListGroups.







So, in the case of CollapsingRecordNode, there are 3 toplevel GoObjects in the sample (the title bar, First Section and Second Section). When TopIndex is 1, the title bar “scrolls off” (it’s actually just set Visible=false). When TopIndex is set to 2, all of “First Section” is gone.



The CollapsingRecordNode sample node is coded to assume TopIndex = -1, (variable overall height based on what is collapsed and what isn’t, rather than fixed height with a scrollbar to see things that don’t fit).



If you really wanted scrolling, you probably wouldn’t want the title bar to scroll away, and you’d want “First Section” to go away over 4 “scroll down” clicks, not 1.



To do that, you’d have to re-do LayoutChildren (as least) to interpret TopIndex so that it was looked at recursively with respect to GoListGroups within GoListGroups. But that doesn’t look easy…

Thanks! This seems to work.

Is there any update to this question? Basically, what is the recommended approach to allowing the user to scroll the items in a GoListGroup?

Scrolling a GoListGroup is demonstrated in ScrollingMultiTextNode and ScrollingRecordNode (both samples in NodeLinkDemo).



If you’re asking about CollapsingRecordNode, nothing has changed on that since my post above. Adding scrolling to CRN is not on my to-do list.