diff options
Diffstat (limited to 'scene/gui/subviewport_container.cpp')
-rw-r--r-- | scene/gui/subviewport_container.cpp | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/scene/gui/subviewport_container.cpp b/scene/gui/subviewport_container.cpp index 9105837486..851a94b32f 100644 --- a/scene/gui/subviewport_container.cpp +++ b/scene/gui/subviewport_container.cpp @@ -147,12 +147,16 @@ void SubViewportContainer::_notification(int p_what) { } } break; - case NOTIFICATION_MOUSE_ENTER: { - _notify_viewports(NOTIFICATION_VP_MOUSE_ENTER); + case NOTIFICATION_FOCUS_ENTER: { + // If focused, send InputEvent to the SubViewport before the Gui-Input stage. + set_process_input(true); + set_process_unhandled_input(false); } break; - case NOTIFICATION_MOUSE_EXIT: { - _notify_viewports(NOTIFICATION_VP_MOUSE_EXIT); + case NOTIFICATION_FOCUS_EXIT: { + // A different Control has focus and should receive Gui-Input before the InputEvent is sent to the SubViewport. + set_process_input(false); + set_process_unhandled_input(true); } break; } } @@ -168,6 +172,14 @@ void SubViewportContainer::_notify_viewports(int p_notification) { } void SubViewportContainer::input(const Ref<InputEvent> &p_event) { + _propagate_nonpositional_event(p_event); +} + +void SubViewportContainer::unhandled_input(const Ref<InputEvent> &p_event) { + _propagate_nonpositional_event(p_event); +} + +void SubViewportContainer::_propagate_nonpositional_event(const Ref<InputEvent> &p_event) { ERR_FAIL_COND(p_event.is_null()); if (Engine::get_singleton()->is_editor_hint()) { @@ -247,6 +259,10 @@ PackedStringArray SubViewportContainer::get_configuration_warnings() const { warnings.push_back(RTR("This node doesn't have a SubViewport as child, so it can't display its intended content.\nConsider adding a SubViewport as a child to provide something displayable.")); } + if (get_default_cursor_shape() != Control::CURSOR_ARROW) { + warnings.push_back(RTR("The default mouse cursor shape of SubViewportContainer has no effect.\nConsider leaving it at its initial value `CURSOR_ARROW`.")); + } + return warnings; } @@ -262,5 +278,6 @@ void SubViewportContainer::_bind_methods() { } SubViewportContainer::SubViewportContainer() { - set_process_input(true); + set_process_unhandled_input(true); + set_focus_mode(FOCUS_CLICK); } |