Page 1 of 1

[2.0.43] "list-box" GUI elements ignore "enabled" property

Posted: Wed Apr 02, 2025 1:05 pm
by noodlebox
GUI elements with the "list-box" type always behave as if they are "enabled", regardless of the value of the property. For comparison, a "drop-down" element with the same properties behaves as expected:

Code: Select all

game.player.gui.screen.add{name="test", type="frame", caption="list-box test"}
e1 = game.player.gui.screen["test"].add{type="list-box", items={"one","two","three"}, enabled=false}
e2 = game.player.gui.screen["test"].add{type="drop-down", items={"one","two","three"}, enabled=false}
script.on_event(defines.events.on_gui_selection_state_changed, function(event) game.print(serpent.line(event)) end)
Screenshot from 2025-04-02 08-47-01.png
Screenshot from 2025-04-02 08-47-01.png (16.09 KiB) Viewed 424 times
Toggling "enabled" for each, the drop-down becomes interactable or not, as expected. The list-box always behaves as if "enabled":

Code: Select all

e1.enabled = true
e2.enabled = true

Re: [2.0.43] "list-box" GUI elements ignore "enabled" property

Posted: Wed Apr 02, 2025 4:47 pm
by Rseding91
Looking into this, it seems to be the same root problem of setting enabled = false on a frame/table. It only disables interaction for the widget itself - not the children. In the case of a listbox the children are buttons/text and those are not disabled. However, those are also not exposed in the API for a mod to set enabled on - meaning there's no way for a mod to disable values in a listbox currently.

Re: [2.0.43] "list-box" GUI elements ignore "enabled" property

Posted: Thu Apr 10, 2025 1:28 pm
by _CodeGreen
A simple workaround for this would be to not use the list box element and instead make it yourself with a frame and a few buttons. You should be able to use the same styles that the list box uses and have it look exactly the same, the only downside being you have to code the logic yourself. Luckily that isn't too hard though.

Re: [2.0.43] "list-box" GUI elements ignore "enabled" property

Posted: Mon Apr 21, 2025 6:11 pm
by Rseding91
I have no solution for this at the moment. Maybe some day someone might change the GUI logic such that this could work. But, until then - this is in limbo.