Android: Fix back button sometimes not working as ESC (#14743)

This commit is contained in:
grorp 2024-06-11 22:37:57 +02:00 committed by GitHub
parent ae4cd1ebf1
commit 85878d894a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 7 additions and 13 deletions

@ -1267,7 +1267,8 @@ void CIrrDeviceSDL::createKeyMap()
// buttons missing // buttons missing
KeyMap.push_back(SKeyMap(SDLK_AC_BACK, KEY_CANCEL)); // Android back button = ESC
KeyMap.push_back(SKeyMap(SDLK_AC_BACK, KEY_ESCAPE));
KeyMap.push_back(SKeyMap(SDLK_BACKSPACE, KEY_BACK)); KeyMap.push_back(SKeyMap(SDLK_BACKSPACE, KEY_BACK));
KeyMap.push_back(SKeyMap(SDLK_TAB, KEY_TAB)); KeyMap.push_back(SKeyMap(SDLK_TAB, KEY_TAB));

@ -94,7 +94,6 @@ void KeyCache::populate()
handler->listenForKey(k); handler->listenForKey(k);
} }
handler->listenForKey(EscapeKey); handler->listenForKey(EscapeKey);
handler->listenForKey(CancelKey);
} }
} }

@ -309,7 +309,7 @@ public:
virtual bool cancelPressed() virtual bool cancelPressed()
{ {
return wasKeyDown(KeyType::ESC) || m_receiver->WasKeyDown(CancelKey); return wasKeyDown(KeyType::ESC);
} }
virtual void clearWasKeyPressed() virtual void clearWasKeyPressed()

@ -348,7 +348,6 @@ const char *KeyPress::name() const
} }
const KeyPress EscapeKey("KEY_ESCAPE"); const KeyPress EscapeKey("KEY_ESCAPE");
const KeyPress CancelKey("KEY_CANCEL");
const KeyPress LMBKey("KEY_LBUTTON"); const KeyPress LMBKey("KEY_LBUTTON");
const KeyPress MMBKey("KEY_MBUTTON"); const KeyPress MMBKey("KEY_MBUTTON");

@ -66,7 +66,6 @@ protected:
// Global defines for convenience // Global defines for convenience
extern const KeyPress EscapeKey; extern const KeyPress EscapeKey;
extern const KeyPress CancelKey;
extern const KeyPress LMBKey; extern const KeyPress LMBKey;
extern const KeyPress MMBKey; // Middle Mouse Button extern const KeyPress MMBKey; // Middle Mouse Button

@ -4105,7 +4105,7 @@ bool GUIFormSpecMenu::preprocessEvent(const SEvent& event)
// Fix Esc/Return key being eaten by checkboxen and tables // Fix Esc/Return key being eaten by checkboxen and tables
if (event.EventType == EET_KEY_INPUT_EVENT) { if (event.EventType == EET_KEY_INPUT_EVENT) {
KeyPress kp(event.KeyInput); KeyPress kp(event.KeyInput);
if (kp == EscapeKey || kp == CancelKey if (kp == EscapeKey
|| kp == getKeySetting("keymap_inventory") || kp == getKeySetting("keymap_inventory")
|| event.KeyInput.Key==KEY_RETURN) { || event.KeyInput.Key==KEY_RETURN) {
gui::IGUIElement *focused = Environment->getFocus(); gui::IGUIElement *focused = Environment->getFocus();
@ -4173,7 +4173,7 @@ bool GUIFormSpecMenu::OnEvent(const SEvent& event)
if (event.EventType==EET_KEY_INPUT_EVENT) { if (event.EventType==EET_KEY_INPUT_EVENT) {
KeyPress kp(event.KeyInput); KeyPress kp(event.KeyInput);
if (event.KeyInput.PressedDown && ( if (event.KeyInput.PressedDown && (
(kp == EscapeKey) || (kp == CancelKey) || (kp == EscapeKey) ||
((m_client != NULL) && (kp == getKeySetting("keymap_inventory"))))) { ((m_client != NULL) && (kp == getKeySetting("keymap_inventory"))))) {
tryClose(); tryClose();
return true; return true;

@ -160,9 +160,7 @@ void GUIOpenURLMenu::drawMenu()
bool GUIOpenURLMenu::OnEvent(const SEvent &event) bool GUIOpenURLMenu::OnEvent(const SEvent &event)
{ {
if (event.EventType == EET_KEY_INPUT_EVENT) { if (event.EventType == EET_KEY_INPUT_EVENT) {
if ((event.KeyInput.Key == KEY_ESCAPE || if (event.KeyInput.Key == KEY_ESCAPE && event.KeyInput.PressedDown) {
event.KeyInput.Key == KEY_CANCEL) &&
event.KeyInput.PressedDown) {
quitMenu(); quitMenu();
return true; return true;
} }

@ -187,9 +187,7 @@ bool GUIPasswordChange::processInput()
bool GUIPasswordChange::OnEvent(const SEvent &event) bool GUIPasswordChange::OnEvent(const SEvent &event)
{ {
if (event.EventType == EET_KEY_INPUT_EVENT) { if (event.EventType == EET_KEY_INPUT_EVENT) {
if ((event.KeyInput.Key == KEY_ESCAPE || if (event.KeyInput.Key == KEY_ESCAPE && event.KeyInput.PressedDown) {
event.KeyInput.Key == KEY_CANCEL) &&
event.KeyInput.PressedDown) {
quitMenu(); quitMenu();
return true; return true;
} }