Add pressed attribute to GuiElement

Post Reply
User avatar
Therenas
Factorio Staff
Factorio Staff
Posts: 232
Joined: Tue Dec 11, 2018 2:10 pm
Contact:

Add pressed attribute to GuiElement

Post 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.

Rseding91
Factorio Staff
Factorio Staff
Posts: 13209
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Add pressed attribute to GuiElement

Post by Rseding91 »

That's exactly how the base game does it: on selection change the style.
If you want to get ahold of me I'm almost always on Discord.

User avatar
Therenas
Factorio Staff
Factorio Staff
Posts: 232
Joined: Tue Dec 11, 2018 2:10 pm
Contact:

Re: Add pressed attribute to GuiElement

Post 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.

Rseding91
Factorio Staff
Factorio Staff
Posts: 13209
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Add pressed attribute to GuiElement

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

eduran
Filter Inserter
Filter Inserter
Posts: 344
Joined: Fri May 09, 2014 2:52 pm
Contact:

Re: Add pressed attribute to GuiElement

Post 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?

User avatar
raiguard
Factorio Staff
Factorio Staff
Posts: 451
Joined: Wed Dec 13, 2017 8:29 pm
Contact:

Re: Add pressed attribute to GuiElement

Post by raiguard »

This has been implemented in 1.1.82.
Don't forget, you're here forever.

Post Reply

Return to “Implemented mod requests”