Improved input handling with modal dialogs & text boxes

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/irrlicht@3868 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria 2009-08-16 19:36:52 +00:00
parent 600ac7ebf5
commit b7c8b77952
3 changed files with 14 additions and 6 deletions

View File

@ -75,6 +75,8 @@ namespace GUIEngine
PROP_SQUARE
};
static bool isWithinATextBox = false;
/**
* The nearly-abstract base of all widgets (not fully abstract since a bare Widget
* can be created for the sore goal of containing children widgets in a group)
@ -89,8 +91,8 @@ namespace GUIEngine
*/
class Widget : public SkinWidgetContainer
{
friend class EventHandler;
protected:
friend class EventHandler;
friend class RibbonWidget;
friend class Screen;
friend class SpinnerWidget;
@ -126,7 +128,7 @@ namespace GUIEngine
virtual bool mouseHovered(Widget* child) { return false; }
/** override in children if you need to know when the widget is focused */
virtual void focused() {}
virtual void focused() { isWithinATextBox = false; }
/**
* The XML loader stored coords in their raw string form inside this widget.

View File

@ -34,10 +34,16 @@ namespace GUIEngine
{
public:
TextBoxWidget();
~TextBoxWidget()
{
isWithinATextBox = false;
}
void add();
void addItem(const char* item);
virtual void focused() { isWithinATextBox = true; }
core::stringw getText() const;
};
}

View File

@ -451,10 +451,10 @@ bool InputManager::input(const SEvent& event)
StateManager::get()->escapePressed();
return true;
}
// 'backspace' in a modal dialog 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
// dialog instead of erasing a single letter)
if (key == KEY_BACK && GUIEngine::ModalDialog::isADialogActive())
if (key == KEY_BACK && GUIEngine::isWithinATextBox)
{
return false;
}
@ -502,8 +502,8 @@ bool InputManager::input(const SEvent& event)
}
#endif
// block events in all modes but initial menus (except for modal dialogs to allow for typing text)
return getDeviceList()->playerAssignMode() != NO_ASSIGN && !GUIEngine::ModalDialog::isADialogActive();
// block events in all modes but initial menus (except in text boxes to allow typing)
return getDeviceList()->playerAssignMode() != NO_ASSIGN && !GUIEngine::isWithinATextBox;
}
//-----------------------------------------------------------------------------