gd: added input addon

This commit is contained in:
2025-05-27 19:20:46 +02:00
parent d8a1604af9
commit c8d8c7ec25
683 changed files with 21608 additions and 2 deletions

View File

@ -0,0 +1,26 @@
## Tracker that tracks input for a window and injects it into GUIDE.
## Will automatically keep track of sub-windows.
extends Node
## Instruments a sub-window so it forwards input events to GUIDE.
static func _instrument(viewport:Viewport):
if viewport.has_meta("x-guide-instrumented"):
return
var tracker = preload("guide_input_tracker.gd").new()
tracker.process_mode = Node.PROCESS_MODE_ALWAYS
viewport.add_child(tracker, false, Node.INTERNAL_MODE_BACK)
viewport.gui_focus_changed.connect(tracker._control_focused)
## Catches unhandled input and forwards it to GUIDE
func _unhandled_input(event:InputEvent):
GUIDE.inject_input(event)
## Some ... creative code ... to catch events from popup windows
## that are spawned by Godot's control nodes.
func _control_focused(control:Control):
if control is OptionButton or control is ColorPickerButton \
or control is MenuButton or control is TabContainer:
_instrument(control.get_popup())