LuaGUIElement.state :: string [RW]

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
Post Reply
User avatar
ZlovreD
Fast Inserter
Fast Inserter
Posts: 129
Joined: Thu Apr 06, 2017 1:07 pm
Contact:

LuaGUIElement.state :: string [RW]

Post by ZlovreD »

TL;DR
Add "state" field to LuaGUIElement for all "clickable" elements (buttons, tabs and so on)
Value - [clicked/hovered/selected] or nil if none of this.
What ?
Adding "state" field for all element is a time saving addition for mod developers.
For now, if you want to handle all possible states, you must to change style of element by hand.
For example tabs:
If i creating tabs not as part of "tabbed-pane", then i must to write additional handlers to change style for selected one and discard changes for others. Plus "tab-content" behaviour.

Same situation if i want to make group of buttons (usual, radio, checkboxes) when i click one of them, all other must be unselected/disabled and so on. You say a simple 3 line loop? If it were that simple ...

But what if i need to manage more than 2 different state? Additional styles?
Why ?
In some reason this is not been added by default. And as i know, it's most elegant way to manage different states of gui element.
I don't think it is too hard to hardcoded such behaviour. But as result it makes unnecessary to creating additional styles for different states and will minimizing additional code to change state and manage relations.

User avatar
Cooldude2606
Long Handed Inserter
Long Handed Inserter
Posts: 86
Joined: Sat Sep 16, 2017 9:04 pm
Contact:

Re: LuaGUIElement.state :: string [RW]

Post by Cooldude2606 »

This would be really nice to have. A few base game elements use this, for example setting logistic filters.
As I code for a scenario rather than a mod, I dont have the option to define new styles and so that workaround is not an option for me.

On a side note; should this not be under Modding interface requests?
--- Developer for Explosive Gaming factorio community. Find our code on GitHub. Please contact me via our Discord. ---

User avatar
ssilk
Global Moderator
Global Moderator
Posts: 12888
Joined: Tue Apr 16, 2013 10:35 pm
Contact:

Re: LuaGUIElement.state :: string [RW]

Post by ssilk »

moved from suggestions — ssilk

IMHO: some simple css pseudoclass like mechanism.

https://developer.mozilla.org/en-US/doc ... do-classes

https://wiki.selfhtml.org/wiki/CSS/Sele ... ive,_focus
Cool suggestion: Eatable MOUSE-pointers.
Have you used the Advanced Search today?
Need help, question? FAQ - Wiki - Forum help
I still like small signatures...

Post Reply

Return to “Modding interface requests”