Page 1 of 1

[kovarex] [0.17.45][Modded GUI] "Enter" key sets selected state for focused LuaGuiElement button

Posted: Tue Jun 04, 2019 6:08 pm
by eduran
When hitting Enter or Return (assuming they are not bound via control settings) while a LuaGuiElement of type button is focused, that button shows its selected_graphical_set. No event is triggered and the button keeps the selected appearance until you press Enter/Return again. It is my understanding that 'selected' is not meant to be useable by modded GUI elements.

To reproduce execute

Code: Select all

/c game.player.gui.center.add{type = "button", caption = 'Hit the "Enter" key!'}.focus()
and press 'Enter' (the key on the numpad). Return is by default bound to 'Enter vehicle', but shows the same behavior when unbound.

As an example, this is what can happen when custom button styles are used:
buggy_buttons.jpg
buggy_buttons.jpg (76.52 KiB) Viewed 2609 times

Re: [0.17.45][Modded GUI] "Enter" key sets selected state for focused LuaGuiElement button

Posted: Wed Jun 05, 2019 3:06 pm
by Twinsen

Re: [kovarex] [0.17.45][Modded GUI] "Enter" key sets selected state for focused LuaGuiElement button

Posted: Thu Jun 13, 2019 1:31 pm
by kovarex
Thanks for the report.
It was fixed for the next version by removing the tabable functionality from everything but textboxes.

Re: [kovarex] [0.17.45][Modded GUI] "Enter" key sets selected state for focused LuaGuiElement button

Posted: Thu Jun 13, 2019 5:45 pm
by eduran
Thanks for having a look. However, this only solves the most common cause of the problem, not the underlying problem itself. It is still possible to focus buttons with the focus() method or the mouse. If you then hit Enter/Return, the button is toggled into the selected state and stays that way. I would expect it to act as if clicked (or not at all).
You can notice the difference if you run the code I posted above. Click the button and it only stays clicked while LMB is pressed (as it should). Hit Enter and the button toggles permanently.