How to set up a scroll pane properly

Place to get help with not working mods / modding interface.
User avatar
Gergely
Filter Inserter
Filter Inserter
Posts: 633
Joined: Sun Apr 10, 2016 8:31 pm
Contact:

How to set up a scroll pane properly

Post 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?
kikker450
Inserter
Inserter
Posts: 30
Joined: Fri May 05, 2017 9:07 am
Contact:

Re: How to set up a scroll pane properly

Post 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
Post Reply

Return to “Modding help”