ScrollArea trouble

Hi,

I’ve been playing with this GUI today, and it’s been great so far, but I’m having a problem getting ScrollArea to work. When I create a text-only ScrollArea, the text scrolls properly, but the display overflows the vertical bounds of the ScrollArea. If I create a non-text-only ScrollArea and add text to the scroll element, the text clips correctly, but I don’t get a scrollbar. Screenshot

Since I’m using this package for the first time, I am sure I’m just missing something simple - any help spotting it would be great. Here’s my code (simpleInitApp() in a new jMonkey project):

[java]
public void simpleInitApp() {
flyCam.setEnabled(false);

    Screen screen = new Screen(this);
    screen.initialize();
    guiNode.addControl(screen);

    ScrollArea scroller = new ScrollArea(screen, "scr1", new Vector2f(50, 50), new Vector2f(200, 200), true);

    for (byte i = 0; i < 15; i++) {
        scroller.setText(scroller.getText() + "what a long text string this is!");
    }

    ScrollArea scroller2 = new ScrollArea(screen, "scr2", new Vector2f(450, 50), new Vector2f(200, 200), false);
    Element area = scroller2.getScrollableArea();

    for (byte i = 0; i < 15; i++) {
        area.setText(area.getText() + "what a long text string this is!");
    }

    screen.addElement(scroller);
    screen.addElement(scroller2);
}

[/java]

Thank you!

Well… this is a problem I need to fix. It should be setting the clipping layer automatically, however, currently it is not. Sooo… the first problem can be resolved using the following call:

[java]
scroller.setClippingLayer(scroller);
[/java]

Thanks for reporting this, as I forgot that this was an issue!

Actually, I think I provided a ScrollAreaAdapter class that fixes some of these issues. and allows for adding/removing dynamic content to the scroll area. The ScrollAreaAdapter should resolve the second issue you are seeing as well.

Originally the ScrollArea class was designed for internal use only, as there are quirks still and took kind words and prayer to get to work as intended. ScrollAreaAdapter should resolve many of these issues for you.

1 Like

Awesome, thank you. I got it working nicely using ScrollAreaAdapter.

Your GUI libraries seem both straightforward and very capable, so I’m looking forward to learning more. Thank you for all your hard work here.

1 Like