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

We are aware of them, but do not have solutions that don't cause other issues. They go here in order not to take space in the main bug thread list.
User avatar
noodlebox
Burner Inserter
Burner Inserter
Posts: 14
Joined: Mon Oct 09, 2017 3:01 am
Contact:

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

Post 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 365 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
Rseding91
Factorio Staff
Factorio Staff
Posts: 15695
Joined: Wed Jun 11, 2014 5:23 am
Contact:

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

Post 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.
If you want to get ahold of me I'm almost always on Discord.
User avatar
_CodeGreen
Long Handed Inserter
Long Handed Inserter
Posts: 85
Joined: Sat Mar 05, 2022 11:30 am
Contact:

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

Post 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.
My Mods | If you can't make it perfect, make it adjustable
Rseding91
Factorio Staff
Factorio Staff
Posts: 15695
Joined: Wed Jun 11, 2014 5:23 am
Contact:

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

Post 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.
If you want to get ahold of me I'm almost always on Discord.
Post Reply

Return to “Minor issues”