mirror of
https://github.com/ENSL/NS.git
synced 2024-11-29 07:41:53 +00:00
Fix for backspace being held preventing additional text input. Credit to Bacsu.
This commit is contained in:
parent
6d75594419
commit
907ddf8b24
3 changed files with 15 additions and 9 deletions
|
@ -2388,7 +2388,7 @@ int TeamFortressViewport::KeyInput( int down, int keynum, const char *pszCurrent
|
|||
if (m_chatPanel->isVisible())
|
||||
{
|
||||
// Don't let the game handle the input while the user is typing in the chat window.
|
||||
m_chatPanel->KeyEvent();
|
||||
m_chatPanel->KeyEvent(down);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -208,10 +208,11 @@ std::string ChatPanel::UTF8toASCII(unsigned char* multibyte)
|
|||
return ASCIIValue;
|
||||
}
|
||||
|
||||
void ChatPanel::KeyEvent()
|
||||
void ChatPanel::KeyEvent(int iKeydown)
|
||||
{
|
||||
const Uint8 *state = SDL_GetKeyboardState(NULL);
|
||||
|
||||
bool bTextinput;
|
||||
bTextinput = false;
|
||||
while (SDL_PollEvent(&event)) {
|
||||
|
||||
if (event.type == SDL_TEXTINPUT)
|
||||
|
@ -220,6 +221,7 @@ void ChatPanel::KeyEvent()
|
|||
buffer = (unsigned char*)event.text.text;
|
||||
|
||||
mText += UTF8toASCII(buffer);
|
||||
bTextinput = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -227,12 +229,16 @@ void ChatPanel::KeyEvent()
|
|||
if (state[SDL_SCANCODE_ESCAPE])
|
||||
{
|
||||
CancelChat();
|
||||
|
||||
}
|
||||
if (state[SDL_SCANCODE_BACKSPACE])
|
||||
{
|
||||
if (mText.length() > 0)
|
||||
if (iKeydown && !bTextinput)
|
||||
{
|
||||
mText.erase(mText.length() - 1, mText.length());
|
||||
if (mText.length() > 0)
|
||||
{
|
||||
mText.erase(mText.length() - 1, mText.length());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (state[SDL_SCANCODE_RETURN])
|
||||
|
|
|
@ -20,7 +20,7 @@ public:
|
|||
|
||||
void CancelChat();
|
||||
void SetChatMode(std::string sChatMode);
|
||||
void KeyEvent();
|
||||
void KeyEvent(int iKeydown);
|
||||
void KeyDown(int virtualKey, int scanCode);
|
||||
|
||||
// Checks if a key was pushed since the chat window was opened.
|
||||
|
|
Loading…
Reference in a new issue