Page 1 of 1

How to set up a scroll pane properly

Posted: Mon Dec 18, 2017 3:29 pm
by Gergely
How do I set up a scroll pane to display a list that is somewhat long in player.gui.center?

This is what I did:

Code: Select all

player.gui.center.add({type = "frame",name = "popup",direction = "vertical"})
.add({type = "scroll-pane",name = "popup-scroll"}).add(list-setup)
What happened, is that the list streched all the way through the top and the bottom of the screen and the scroll bar did not appear. How do I properly set it up so that it prevents my list from overflowing the screen?

Re: How to set up a scroll pane properly

Posted: Wed Dec 20, 2017 4:31 pm
by kikker450
Define the dimensions of the scroll plane in the code itself. (see more at http://lua-api.factorio.com/0.16.6/LuaStyle.html)

Code: Select all

main_gui = player.gui.center.add({type = "frame",name = "popup",direction = "vertical"})
your_scroll_pane = main_gui.add(({type = "scroll-pane",name = "popup-scroll"})
   your_scroll_pane.style.maximal_height = 200 --for example
or instead of adding each style element separately you can create a style object

or you make a static gui in your data files