Allow temporarily to grab keyboard and/or mouse events
Posted: Wed May 01, 2019 7:37 pm
It would be nice if there was a way to temporarily grab keyboard and/or mouse events (similarly to the way focused text fields intercept most of keystokes).
This event grab could be implemented by adding an additional lua event and a LuaPlayer.grab_input_events(grab_keyboard, grab_mouse) (or similar) method(s) that would initiate the grab.
Grabbing keyboard events would allow to implement more interesting custom GUI elements, while allowing to grab mouse events would enable creating interactive game overlays (when done in conjunction with the rendering API).
The new mouse event could be similar to on_gui_click, but it could contain entity instead of LuaGuiElement. The location of the click in surface coordinates would also be useful.
This event grab could be implemented by adding an additional lua event and a LuaPlayer.grab_input_events(grab_keyboard, grab_mouse) (or similar) method(s) that would initiate the grab.
Grabbing keyboard events would allow to implement more interesting custom GUI elements, while allowing to grab mouse events would enable creating interactive game overlays (when done in conjunction with the rendering API).
The new mouse event could be similar to on_gui_click, but it could contain entity instead of LuaGuiElement. The location of the click in surface coordinates would also be useful.