Page 1 of 1

Check if LuaGuiElement is in focus

Posted: Thu Nov 26, 2020 10:08 pm
by Wichu
Hi there,

Thanks to this topic viewtopic.php?p=315928#p315928 we have the possibility to set the focus to a LuaGuiElement.
Now, how can we check if a LuaGuiElement is still in focus? I haven't found anything on it.

So could we have either:
- On the LuaGuiElement something like is_focused() -> returning boolean true if element is in focus
- On the LuaPlayer something like: gui_element_in_focus() -> returning LuaGuiElement of the element in focus
- On the LuaGui something like: element_in_focus() -> return LuaGuiElement of the element in focus

Since the UI must know this right now (since for example the textfield in focus is displayed differently than "not in focus") I think it should be doable somehow.

What I want to do is: I have an UI (4 function calculator mod) which can be shown with a hotkey. When the UI is not active (but shown) I set the focus to the input-field (also via the hotkey). But now when the input-field is in focus and you press the hotkey I want to close the UI. But for that I need to know if it's in focus or not.

Kind regards,
Wichu

Re: Check if LuaGuiElement is in focus

Posted: Sat Nov 28, 2020 6:23 am
by Rseding91
Sorry, but GUI is not part of the synced game in multiplayer and as such it's not deterministic for mods to read.