Fixed pressing space in text areas (/me should beware about static variables in header files...)
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/irrlicht@4186 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
c3419d8ddb
commit
129c93f4bf
@ -203,7 +203,7 @@ void transmitEvent(Widget* widget, std::string& name, const int playerID)
|
|||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
void render(float elapsed_time)
|
void render(float elapsed_time)
|
||||||
{
|
{
|
||||||
GUIEngine::dt = elapsed_time;
|
GUIEngine::dt = elapsed_time;
|
||||||
|
|
||||||
// ---- menu drawing
|
// ---- menu drawing
|
||||||
|
@ -282,7 +282,7 @@ void EventHandler::processAction(const int action, const unsigned int value, Inp
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case PA_FIRE:
|
case PA_FIRE:
|
||||||
if (pressedDown && !isWithinATextBox)
|
if (pressedDown && !isWithinATextBox())
|
||||||
{
|
{
|
||||||
Widget* w = GUIEngine::getFocusForPlayer(playerID);
|
Widget* w = GUIEngine::getFocusForPlayer(playerID);
|
||||||
if (w == NULL) break;
|
if (w == NULL) break;
|
||||||
|
@ -42,6 +42,17 @@ using namespace gui;
|
|||||||
|
|
||||||
namespace GUIEngine
|
namespace GUIEngine
|
||||||
{
|
{
|
||||||
|
|
||||||
|
static bool g_is_within_a_text_box = false;
|
||||||
|
bool isWithinATextBox()
|
||||||
|
{
|
||||||
|
return g_is_within_a_text_box;
|
||||||
|
}
|
||||||
|
void setWithinATextBox(bool in)
|
||||||
|
{
|
||||||
|
g_is_within_a_text_box = in;
|
||||||
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
Widget::Widget(bool reserve_id)
|
Widget::Widget(bool reserve_id)
|
||||||
{
|
{
|
||||||
|
@ -74,7 +74,8 @@ namespace GUIEngine
|
|||||||
PROP_SQUARE
|
PROP_SQUARE
|
||||||
};
|
};
|
||||||
|
|
||||||
static bool isWithinATextBox = false;
|
bool isWithinATextBox();
|
||||||
|
void setWithinATextBox(bool in);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The nearly-abstract base of all widgets (not fully abstract since a bare Widget
|
* The nearly-abstract base of all widgets (not fully abstract since a bare Widget
|
||||||
@ -121,7 +122,7 @@ namespace GUIEngine
|
|||||||
virtual EventPropagation mouseHovered(Widget* child) { return EVENT_BLOCK; }
|
virtual EventPropagation mouseHovered(Widget* child) { return EVENT_BLOCK; }
|
||||||
|
|
||||||
/** override in children if you need to know when the widget is focused. return whether to block event */
|
/** override in children if you need to know when the widget is focused. return whether to block event */
|
||||||
virtual EventPropagation focused(const int playerID) { isWithinATextBox = false; return EVENT_LET; }
|
virtual EventPropagation focused(const int playerID) { setWithinATextBox(false); return EVENT_LET; }
|
||||||
|
|
||||||
/** override in children if you need to know when the widget is unfocused. */
|
/** override in children if you need to know when the widget is unfocused. */
|
||||||
virtual void unfocused(const int playerID) { }
|
virtual void unfocused(const int playerID) { }
|
||||||
|
@ -55,7 +55,7 @@ EventPropagation TextBoxWidget::focused(const int playerID)
|
|||||||
|
|
||||||
// special case : to work, the text box must receive "irrLicht focus", STK focus is not enough
|
// special case : to work, the text box must receive "irrLicht focus", STK focus is not enough
|
||||||
GUIEngine::getGUIEnv()->setFocus(m_element);
|
GUIEngine::getGUIEnv()->setFocus(m_element);
|
||||||
isWithinATextBox = true;
|
setWithinATextBox(true);
|
||||||
return EVENT_LET;
|
return EVENT_LET;
|
||||||
}
|
}
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
@ -63,6 +63,8 @@ void TextBoxWidget::unfocused(const int playerID)
|
|||||||
{
|
{
|
||||||
assert(playerID == 0); // No support for multiple players in text areas!
|
assert(playerID == 0); // No support for multiple players in text areas!
|
||||||
|
|
||||||
|
setWithinATextBox(false);
|
||||||
|
|
||||||
// special case : to work, the text box must receive "irrLicht focus", STK focus is not enough
|
// special case : to work, the text box must receive "irrLicht focus", STK focus is not enough
|
||||||
// below is a cheap way to unset the irrLicht focus from the widget (nope, 'removeFocus' from
|
// below is a cheap way to unset the irrLicht focus from the widget (nope, 'removeFocus' from
|
||||||
// IGUIEnv doesn't work reliably, not sure why)
|
// IGUIEnv doesn't work reliably, not sure why)
|
||||||
|
@ -34,7 +34,7 @@ namespace GUIEngine
|
|||||||
TextBoxWidget();
|
TextBoxWidget();
|
||||||
~TextBoxWidget()
|
~TextBoxWidget()
|
||||||
{
|
{
|
||||||
isWithinATextBox = false;
|
setWithinATextBox(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void add();
|
void add();
|
||||||
|
@ -461,11 +461,11 @@ 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.
|
||||||
if (key == KEY_BACK && GUIEngine::isWithinATextBox)
|
if (key == KEY_BACK && GUIEngine::isWithinATextBox())
|
||||||
{
|
{
|
||||||
return EVENT_LET;
|
return EVENT_LET;
|
||||||
}
|
}
|
||||||
if (key == KEY_SPACE && GUIEngine::isWithinATextBox)
|
if (key == KEY_SPACE && GUIEngine::isWithinATextBox())
|
||||||
{
|
{
|
||||||
return EVENT_LET;
|
return EVENT_LET;
|
||||||
}
|
}
|
||||||
@ -515,7 +515,7 @@ EventPropagation InputManager::input(const SEvent& event)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// block events in all modes but initial menus (except in text boxes to allow typing, and exceptm in modal dialogs in-game)
|
// block events in all modes but initial menus (except in text boxes to allow typing, and exceptm in modal dialogs in-game)
|
||||||
if (getDeviceList()->playerAssignMode() != NO_ASSIGN && !GUIEngine::isWithinATextBox &&
|
if (getDeviceList()->playerAssignMode() != NO_ASSIGN && !GUIEngine::isWithinATextBox() &&
|
||||||
(!GUIEngine::ModalDialog::isADialogActive() && StateManager::get()->getGameState() == GUIEngine::GAME))
|
(!GUIEngine::ModalDialog::isADialogActive() && StateManager::get()->getGameState() == GUIEngine::GAME))
|
||||||
{
|
{
|
||||||
return EVENT_BLOCK;
|
return EVENT_BLOCK;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user