Hello. I am attempting to create an interface with a slider and number field, similar to many vanilla settings GUIs. In order to emulate exactly how input sanitation works in vanilla, I need to be able to tell when the user "defocuses" the textbox.
There is currently no way to read the focused state of a GUI element, so I would like to request that that capability be added. And in order to avoid the necessity of having an on_tick() event to keep track of the focused state, some sort of on_gui_focused_state_changed event would be nice.
Thanks in advance!
- raiguard
2019-07-13 13_00_44-Factorio 0.17.56.png (45.58 KiB) Viewed 1757 times
Sorry, that's not what I meant. I have already done that as well. What I need this capability for is to emulate vanilla's sanity checking:
Vanilla doesn't actually edit the user's input while they're typing, but will correct it when they defocus the textfield. This is the behavior I am trying to emulate, which is impossible without what I requested.
The best that is possible now is to sanitize as the user types, but that can be very annoying since it won't let you completely replace the number very easily.
As an aside, it would be nice if pressing enter would defocus the textfield, like what happens with vanilla textfields.
You can kind of catch the unfocus by listening to on_gui_click, and checking if the clicked element is not the one that should be reset, and run your code from there. It it not really reliable though, because not everything that defocuses fires on_gui_clicked.
Rseding91 wrote: ↑Sun Jul 14, 2019 1:56 pm
You're asking for the wrong thing. You should have just asked for support to do exactly what the base game is doing in that text field.
Rseding91 wrote: ↑Sun Jul 14, 2019 1:56 pm
You're asking for the wrong thing. You should have just asked for support to do exactly what the base game is doing in that text field.
Well I was trying to generalize it. I figured that something more general that could have lots of usecases would be more likely to make it in, than something very specific.