[0.17.76] Scrolling functions don't work when elements are yet to be displayed/updated

We are aware of them, but they have low priority. We have more important things to do. They go here in order not to take space in the main bug thread list.
Post Reply
kubel34
Burner Inserter
Burner Inserter
Posts: 5
Joined: Mon Aug 26, 2019 5:48 pm
Contact:

[0.17.76] Scrolling functions don't work when elements are yet to be displayed/updated

Post by kubel34 »

The scrolling functions (scroll_to_top, scroll_to_bottom ...) do nothing when the element (a scroll-pane or a textbox) isn't shown/updated yet, that is to say when the function is called in the same tick as when its contents/text is set.

In this exemple, we create a string with a lot of lines and display it in a textbox with a fixed height, causing a scrollbar to appear. If we want the scrollbar to be at the top immediately, we cannot use the following command:

Code: Select all

/c
local bigText = ""
for i = 1, 100 do 
	bigText = bigText .. "\n"
end
bigText = bigText .. "A"
local textbox = game.player.gui.center.add{type="text-box", name="test", text=""}
textbox.style.maximal_height = 800
textbox.text = bigText
textbox.scroll_to_top()
The position of the scrollbar is set to its default, which is at the bottom.

However doing it in two commands work:

Code: Select all

/c
local bigText = ""
for i = 1, 100 do 
	bigText = bigText .. "\n"
end
bigText = bigText .. "A"
local textbox = game.player.gui.center.add{type="text-box", name="test", text=""}
textbox.style.maximal_height = 800
textbox.text = bigText

Code: Select all

/c game.player.gui.center["test"].scroll_to_top()
This also affects scroll-panes, but their default position is at the top:

Code: Select all

/c
local bigText = ""
for i = 1, 100 do 
	bigText = bigText .. "\n"
end
bigText = bigText .. "A"
local scroll = game.player.gui.center.add{type="scroll-pane", name="scroll"}
local textbox = scroll.add{type = "text-box", name = "test", text = bigText}
scroll.scroll_to_bottom()
I am making a mod where I need to dynamically change the content of a textbox with a fixed height, and I cannot use those functions in the same tick as when I update the GUI. The only reliable workaround I have found is to schedule the scrolling action in the next tick, but without using events as they are executed in the same tick as I schedule them.

Rseding91
Factorio Staff
Factorio Staff
Posts: 13209
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [0.17.76] Scrolling functions don't work when elements are yet to be displayed/updated

Post by Rseding91 »

Thanks for the report. I don't think this will ever be fixed - that's just how GUI works in Factorio unfortunately.
If you want to get ahold of me I'm almost always on Discord.

Post Reply

Return to “Minor issues”