diff --git a/src/openrct2-ui/input/InputManager.cpp b/src/openrct2-ui/input/InputManager.cpp index 115eef910e..3c81dc477a 100644 --- a/src/openrct2-ui/input/InputManager.cpp +++ b/src/openrct2-ui/input/InputManager.cpp @@ -288,13 +288,16 @@ void InputManager::ProcessHoldEvents() _viewScroll.x = 0; _viewScroll.y = 0; - auto& shortcutManager = GetShortcutManager(); - if (!shortcutManager.IsPendingShortcutChange()) + if (!HasTextInputFocus()) { - ProcessViewScrollEvent(ShortcutId::ViewScrollUp, { 0, -1 }); - ProcessViewScrollEvent(ShortcutId::ViewScrollDown, { 0, 1 }); - ProcessViewScrollEvent(ShortcutId::ViewScrollLeft, { -1, 0 }); - ProcessViewScrollEvent(ShortcutId::ViewScrollRight, { 1, 0 }); + auto& shortcutManager = GetShortcutManager(); + if (!shortcutManager.IsPendingShortcutChange()) + { + ProcessViewScrollEvent(ShortcutId::ViewScrollUp, { 0, -1 }); + ProcessViewScrollEvent(ShortcutId::ViewScrollDown, { 0, 1 }); + ProcessViewScrollEvent(ShortcutId::ViewScrollLeft, { -1, 0 }); + ProcessViewScrollEvent(ShortcutId::ViewScrollRight, { 1, 0 }); + } } } @@ -377,3 +380,19 @@ bool InputManager::GetState(const ShortcutInput& shortcut) const } return false; } + +bool InputManager::HasTextInputFocus() const +{ + if (gUsingWidgetTextBox || gChatOpen) + return true; + + auto w = window_find_by_class(WC_TEXTINPUT); + if (w != nullptr) + return true; + + auto& console = GetInGameConsole(); + if (console.IsOpen()) + return true; + + return false; +} diff --git a/src/openrct2-ui/input/InputManager.h b/src/openrct2-ui/input/InputManager.h index a25776cfb9..a1f389cd55 100644 --- a/src/openrct2-ui/input/InputManager.h +++ b/src/openrct2-ui/input/InputManager.h @@ -67,6 +67,8 @@ namespace OpenRCT2::Ui bool GetState(const RegisteredShortcut& shortcut) const; bool GetState(const ShortcutInput& shortcut) const; + bool HasTextInputFocus() const; + public: void QueueInputEvent(const SDL_Event& e); void QueueInputEvent(InputEvent&& e);