Check if LuaGuiElement is in focus

Things that we aren't going to implement
Post Reply
Wichu
Manual Inserter
Manual Inserter
Posts: 1
Joined: Thu Nov 26, 2020 9:51 pm
Contact:

Check if LuaGuiElement is in focus

Post 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

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

Re: Check if LuaGuiElement is in focus

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

Post Reply

Return to “Won't implement”