mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-15 11:03:00 +01:00
Fix #14194: Pressing WASD in text box moves main viewport, too
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user