summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorewewukek <ewewukek@gmail.com>2024-04-02 08:18:17 +0300
committerewewukek <ewewukek@gmail.com>2024-04-02 08:18:17 +0300
commit21e3230244dae0da04571c405d075bddc87bdb89 (patch)
tree43c6af543461fde05ad0f3c34a89c82a15ad582a
parent4b049200df42e6078d8ff2ae589f09c49ab9647d (diff)
downloadmanaverse-21e3230244dae0da04571c405d075bddc87bdb89.tar.gz
manaverse-21e3230244dae0da04571c405d075bddc87bdb89.tar.bz2
manaverse-21e3230244dae0da04571c405d075bddc87bdb89.tar.xz
manaverse-21e3230244dae0da04571c405d075bddc87bdb89.zip
Consume input event in QuitDialog instead of relying on a hack
-rw-r--r--src/gui/windows/quitdialog.cpp5
-rw-r--r--src/input/inputmanager.cpp22
2 files changed, 12 insertions, 15 deletions
diff --git a/src/gui/windows/quitdialog.cpp b/src/gui/windows/quitdialog.cpp
index 66d330af9..7be0a08f9 100644
--- a/src/gui/windows/quitdialog.cpp
+++ b/src/gui/windows/quitdialog.cpp
@@ -210,6 +210,7 @@ void QuitDialog::keyPressed(KeyEvent &event)
{
const InputActionT actionId = event.getActionId();
int dir = 0;
+ bool consume = true;
PRAGMA45(GCC diagnostic push)
PRAGMA45(GCC diagnostic ignored "-Wswitch-enum")
@@ -229,10 +230,14 @@ void QuitDialog::keyPressed(KeyEvent &event)
dir = 1;
break;
default:
+ consume = false;
break;
}
PRAGMA45(GCC diagnostic pop)
+ if (consume)
+ event.consume();
+
if (dir != 0)
{
STD_VECTOR<RadioButton*>::const_iterator it = mOptions.begin();
diff --git a/src/input/inputmanager.cpp b/src/input/inputmanager.cpp
index d1b2ae380..497913913 100644
--- a/src/input/inputmanager.cpp
+++ b/src/input/inputmanager.cpp
@@ -691,21 +691,7 @@ bool InputManager::handleEvent(const SDL_Event &restrict event) restrict2
BLOCK_END("InputManager::handleEvent")
return true;
}
-
keyboard.handleActivateKey(event);
- // send straight to gui for certain windows
-#ifndef DYECMD
- if ((quitDialog != nullptr) || TextDialog::isActive())
- {
- if (guiInput != nullptr)
- guiInput->pushInput(event);
- if (gui != nullptr)
- gui->handleInput();
- BLOCK_END("InputManager::handleEvent")
- return true;
- }
-#endif // DYECMD
-
break;
}
case SDL_KEYUP:
@@ -767,9 +753,15 @@ bool InputManager::handleEvent(const SDL_Event &restrict event) restrict2
guiInput->pushInput(event);
if (gui != nullptr)
{
- const bool res = gui->handleInput();
+ bool res = gui->handleInput();
+#ifndef DYECMD
+ // always treat keyboard input as handled if a text dialog is active
+ if (event.type == SDL_KEYDOWN && TextDialog::isActive())
+ res = true;
+#endif // DYECMD
const bool joystickActionEvent =
joystick != nullptr && joystick->isActionEvent(event);
+ // stop processing input if event is consumed by the gui
if (res && (event.type == SDL_KEYDOWN || joystickActionEvent))
{
BLOCK_END("InputManager::handleEvent")