Fixed typing player names when some letters are mapped to accelerate/brake/fire/etc... in some keyboard config. identified a FIXME and cleaned up another bit of code on the way

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@5341 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria 2010-05-02 00:22:35 +00:00
parent ac25665d1f
commit 17d871732d
2 changed files with 29 additions and 9 deletions

View File

@ -112,7 +112,7 @@ EventPropagation EventHandler::onGUIEvent(const SEvent& event)
// These events are only triggered by keyboard/mouse (or so I hope...) // These events are only triggered by keyboard/mouse (or so I hope...)
const int playerID = input_manager->getPlayerKeyboardID(); const int playerID = input_manager->getPlayerKeyboardID();
if (input_manager->masterPlayerOnly() && playerID != 0) break; if (input_manager->masterPlayerOnly() && playerID != PLAYER_ID_GAME_MASTER) break;
else if (playerID != -1) return onWidgetActivated(w, playerID); else if (playerID != -1) return onWidgetActivated(w, playerID);
else break; else break;
} }

View File

@ -561,14 +561,17 @@ EventPropagation InputManager::input(const SEvent& event)
} }
// 'backspace' in a text control must never be mapped, since user can be in a text // 'backspace' in a text control must never be mapped, since user can be in a text
// area trying to erase text (and if it's mapped to rescue that would dismiss the // area trying to erase text (and if it's mapped to rescue that would dismiss the
// dialog instead of erasing a single letter). Same for spacebar. // dialog instead of erasing a single letter). Same for spacebar. Same for letters.
if (key == KEY_BACK && GUIEngine::isWithinATextBox()) if (GUIEngine::isWithinATextBox())
{ {
return EVENT_LET; if (key == KEY_BACK || key == KEY_SPACE || key == KEY_SHIFT)
} {
if (key == KEY_SPACE && GUIEngine::isWithinATextBox()) return EVENT_LET;
{ }
return EVENT_LET; if (key >= KEY_KEY_0 && key <= KEY_KEY_Z)
{
return EVENT_LET;
}
} }
const bool wasInTextBox = GUIEngine::isWithinATextBox(); const bool wasInTextBox = GUIEngine::isWithinATextBox();
@ -594,6 +597,21 @@ EventPropagation InputManager::input(const SEvent& event)
} }
else else
{ {
// 'backspace' in a text control must never be mapped, since user can be in a text
// area trying to erase text (and if it's mapped to rescue that would dismiss the
// dialog instead of erasing a single letter). Same for spacebar. Same for letters.
if (GUIEngine::isWithinATextBox())
{
if (key == KEY_BACK || key == KEY_SPACE || key == KEY_SHIFT)
{
return EVENT_LET;
}
if (key >= KEY_KEY_0 && key <= KEY_KEY_Z)
{
return EVENT_LET;
}
}
dispatchInput(Input::IT_KEYBOARD, 0, key, 0, 0); dispatchInput(Input::IT_KEYBOARD, 0, key, 0, 0);
return EVENT_BLOCK; // Don't propagate key up events return EVENT_BLOCK; // Don't propagate key up events
} }
@ -623,7 +641,9 @@ EventPropagation InputManager::input(const SEvent& event)
} }
#endif #endif
// block events in all modes but initial menus (except in text boxes to allow typing, and except in modal dialogs in-game) // block events in all modes but initial menus (except in text boxes to allow typing,
// and except in modal dialogs in-game)
// FIXME: 1) that's awful logic 2) that's not what the code below does, events are never blocked in menus
if (getDeviceList()->getAssignMode() != NO_ASSIGN && !GUIEngine::isWithinATextBox() && if (getDeviceList()->getAssignMode() != NO_ASSIGN && !GUIEngine::isWithinATextBox() &&
(!GUIEngine::ModalDialog::isADialogActive() && StateManager::get()->getGameState() == GUIEngine::GAME)) (!GUIEngine::ModalDialog::isADialogActive() && StateManager::get()->getGameState() == GUIEngine::GAME))
{ {