Make sure that at least one backspace action is triggered when backspace key was used on screen keyboard.

This makes it working for gamepads.
This commit is contained in:
Deve 2018-10-24 00:23:18 +02:00
parent e585c26833
commit 2a4c5ad557
2 changed files with 9 additions and 2 deletions

View File

@ -83,6 +83,7 @@ ScreenKeyboard::ScreenKeyboard(float percent_width, float percent_height,
m_edit_box = edit_box; m_edit_box = edit_box;
m_back_button = NULL; m_back_button = NULL;
m_repeat_time = 0; m_repeat_time = 0;
m_back_button_pressed = false;
init(); init();
} // ScreenKeyboard } // ScreenKeyboard
@ -264,7 +265,7 @@ void ScreenKeyboard::assignButtons(ButtonsType buttons_type)
void ScreenKeyboard::onUpdate(float dt) void ScreenKeyboard::onUpdate(float dt)
{ {
if (m_back_button->isPressed()) if (m_back_button->isPressed() || m_back_button_pressed)
{ {
const unsigned int repeat_rate = 40; const unsigned int repeat_rate = 40;
const unsigned int repeat_delay = 400; const unsigned int repeat_delay = 400;
@ -290,8 +291,10 @@ void ScreenKeyboard::onUpdate(float dt)
m_repeat_time += (unsigned int)(dt * 1000); m_repeat_time += (unsigned int)(dt * 1000);
} }
else
if (!m_back_button->isPressed())
{ {
m_back_button_pressed = false;
m_repeat_time = 0; m_repeat_time = 0;
} }
} }
@ -348,6 +351,7 @@ EventPropagation ScreenKeyboard::processEvent(const std::string& eventSource)
else if (eventSource == "Back") else if (eventSource == "Back")
{ {
send_event = false; send_event = false;
m_back_button_pressed = true;
} }
else if (eventSource == "Space") else if (eventSource == "Space")
{ {

View File

@ -71,6 +71,9 @@ namespace GUIEngine
/** A time for repeat key feature */ /** A time for repeat key feature */
unsigned int m_repeat_time; unsigned int m_repeat_time;
/** True if backspace button was pressed */
bool m_back_button_pressed;
/** The edit box that is assigned to the keyboard */ /** The edit box that is assigned to the keyboard */
CGUIEditBox* m_edit_box; CGUIEditBox* m_edit_box;