Make SubViewportContainer event propagation aware of focused Control

Propagate `InputEvents` without position either
- during the Input-stage, when it has focus or
- during the Unhandled-Input-stage, otherwise

This makes sure that Gui-Input happens in the correct order.

Move "Unhandled key Input" handling before "Unhandled Input" handling,
so that Unicode input with Alt / Ctrl modifiers are sent to the nodes
in the correct order.

Change the default focus mode of `SubViewportContainer` from
`FOCUS_NONE` to `FOCUS_CLICK`, to automatically remove focus from
other `Control`-nodes, when clicking inside a `SubViewport`.
This commit is contained in:
Markus Sauermann
2023-07-09 19:23:19 +02:00
parent 85c9db592f
commit e6386bc843
5 changed files with 33 additions and 9 deletions

View File

@@ -41,6 +41,7 @@ class SubViewportContainer : public Container {
void _notify_viewports(int p_notification);
bool _is_propagated_in_gui_input(const Ref<InputEvent> &p_event);
void _send_event_to_viewports(const Ref<InputEvent> &p_event);
void _propagate_nonpositional_event(const Ref<InputEvent> &p_event);
protected:
void _notification(int p_what);
@@ -54,6 +55,7 @@ public:
bool is_stretch_enabled() const;
virtual void input(const Ref<InputEvent> &p_event) override;
virtual void unhandled_input(const Ref<InputEvent> &p_event) override;
virtual void gui_input(const Ref<InputEvent> &p_event) override;
void set_stretch_shrink(int p_shrink);
int get_stretch_shrink() const;