Hey.
I’m trying to dynamically update the height of a container panel inside a scrollpanel based on the content inside. I’ve tried a lot of different things but I could not get the scrollbar to react properly to this.
First let me note that the panel I have as the child root of the scrollpane has a vertical childlayout.
I’ve made sure I’m adding the elements to the correct parent ("#nifty-scrollpanel-child-root" inside the scrollpanel), I can see them lined up vertically.
I’ve tried changing the size of the panel to the proper size based on size of elements I add to it:
chitListPanel.setConstraintHeight(new SizeValue((IDs.length*(chitSize+chitSpacing*2))+"px"));
chitListPanel.getParent().layoutElements();
These “chits” are the elements I add into the panel.
However, this does not work. The scrollbar’s position handle is 100% of the scrollpanel’s height and cannot be moved, it thinks that the visible area is a 100% of the panel inside. I double checked, the logic in the code above returns something around 1100px whereas the visible area height is 600px.
I’ve tried to update it in a number of ways
tooltipScrollpanel.getElement().findElementById("#nifty-internal-vertical-scrollbar").getControl(ScrollbarControl.class).setWorldMax(1200);
tooltipScrollpanel.getElement().findElementById("#nifty-internal-vertical-scrollbar").getControl(ScrollbarControl.class).setWorldPageSize(600);
tooltipScrollpanel.getElement().findElementById("#nifty-internal-vertical-scrollbar").getControl(ScrollbarControl.class).layoutCallback();
…and a wide variety of other gobbledygook in all sorts of combinations:
tooltipScrollpanel.getElement().findElementById("#nifty-internal-vertical-scrollbar").getControl(ScrollbarControl.class).getElement().layoutElements();
tooltipScrollpanel.getElement().findElementById("#nifty-internal-vertical-scrollbar").getControl(ScrollbarControl.class).setValue(0.f);
tooltipScrollpanel.setVerticalPos(0f);
tooltipScrollpanel.setUp(1f, .1f, 1f, 1f, ScrollPanel.AutoScroll.OFF);
tooltipScrollpanel.getElement().getParent().layoutElements();
nifty.executeEndOfFrameElementActions();
But I mostly got two results: either the scrollbar is stuck like before, or it allows dragging but stays the full height of the scrollpanel, making it go out of bounds at the bottom when scrolled down.
I’m out of ideas. Somebody please help me.