How to properly feed / redirect event to a designated Control node?

Godot Version

4.2.2

Question

I need to create a popup window for my plugin - similar to how Quick Open works in Godot. I see that in the engine they just call ->gui_input(event) directly on the node they need (a Tree in this case). Source: godot/editor/editor_quick_open.cpp at 0a9d8f04c10870c0f9f7bbd2e0505edc8494e299 · godotengine/godot · GitHub

However, in GDScript there’s no such method. I tried to emulate similar behavior with the following, but with no success:

line_edit.gui_input.connect(func(event: InputEvent) -> void:
  var copy := event.duplicate()
  line_edit.accept_event()
  tree.grab_focus()
  Input.parse_input_event(copy)
  line_edit.grab_focus()
)

Am I doing something wrong?

Ok, it appears to be a bad idea to grab_focus() with different controls within the same frame (or from within function that is handling the gui_input signal). Now I split this logic and only grab_focus() once.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.