Page 1 of 1

Add pressed attribute to GuiElement

Posted: Thu Jun 06, 2019 1:42 pm
by Therenas
I'd like it if GuiElements had a boolean attribute (maybe named element.pressed) that would set the style of the button to it's clicked_graphical_set while pressed = true. It would not react to clicks or hovers, but would still show a tooltip. We can currently do this by defining a new style for the pressed version of the button, but that is a bit tedious, especially as the necessary graphical set is already right there in the style prototype.

This could then be used to easily used to achieve this effect:
Image

Possible conflicts could arise if both this new attribute and enabled = false is set. In that case, I would just ignore the pressed attribute and show the button as disabled.

Re: Add pressed attribute to GuiElement

Posted: Thu Jun 06, 2019 3:10 pm
by Rseding91
That's exactly how the base game does it: on selection change the style.

Re: Add pressed attribute to GuiElement

Posted: Thu Jun 06, 2019 6:09 pm
by Therenas
Wouldn't it be nicer to have an attribute that does this for you? It's not a major issue, it would just be nicer to use.

Re: Add pressed attribute to GuiElement

Posted: Thu Jun 06, 2019 8:50 pm
by Rseding91
Therenas wrote:
Thu Jun 06, 2019 6:09 pm
Wouldn't it be nicer to have an attribute that does this for you? It's not a major issue, it would just be nicer to use.
No, that just adds extra complexity to every single widget out there you want to do it with. Styles are already universal.

Re: Add pressed attribute to GuiElement

Posted: Thu Jun 06, 2019 8:52 pm
by eduran
Rseding91 wrote:
Thu Jun 06, 2019 3:10 pm
That's exactly how the base game does it: on selection change the style.
Why do button styles have a selected_graphical_set if it isn't used in the base game?

Re: Add pressed attribute to GuiElement

Posted: Mon May 22, 2023 3:10 pm
by raiguard
This has been implemented in 1.1.82.