Page 1 of 1

LuaGUIElement.state :: string [RW]

Posted: Mon Jun 08, 2020 11:49 pm
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.

Re: LuaGUIElement.state :: string [RW]

Posted: Tue Jun 09, 2020 2:41 pm
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?

Re: LuaGUIElement.state :: string [RW]

Posted: Wed Jun 10, 2020 8:56 am
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