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())
|
if (m_chatPanel->isVisible())
|
||||||
{
|
{
|
||||||
// Don't let the game handle the input while the user is typing in the chat window.
|
// 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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -208,10 +208,11 @@ std::string ChatPanel::UTF8toASCII(unsigned char* multibyte)
|
||||||
return ASCIIValue;
|
return ASCIIValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatPanel::KeyEvent()
|
void ChatPanel::KeyEvent(int iKeydown)
|
||||||
{
|
{
|
||||||
const Uint8 *state = SDL_GetKeyboardState(NULL);
|
const Uint8 *state = SDL_GetKeyboardState(NULL);
|
||||||
|
bool bTextinput;
|
||||||
|
bTextinput = false;
|
||||||
while (SDL_PollEvent(&event)) {
|
while (SDL_PollEvent(&event)) {
|
||||||
|
|
||||||
if (event.type == SDL_TEXTINPUT)
|
if (event.type == SDL_TEXTINPUT)
|
||||||
|
@ -220,6 +221,7 @@ void ChatPanel::KeyEvent()
|
||||||
buffer = (unsigned char*)event.text.text;
|
buffer = (unsigned char*)event.text.text;
|
||||||
|
|
||||||
mText += UTF8toASCII(buffer);
|
mText += UTF8toASCII(buffer);
|
||||||
|
bTextinput = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -227,14 +229,18 @@ void ChatPanel::KeyEvent()
|
||||||
if (state[SDL_SCANCODE_ESCAPE])
|
if (state[SDL_SCANCODE_ESCAPE])
|
||||||
{
|
{
|
||||||
CancelChat();
|
CancelChat();
|
||||||
|
|
||||||
}
|
}
|
||||||
if (state[SDL_SCANCODE_BACKSPACE])
|
if (state[SDL_SCANCODE_BACKSPACE])
|
||||||
|
{
|
||||||
|
if (iKeydown && !bTextinput)
|
||||||
{
|
{
|
||||||
if (mText.length() > 0)
|
if (mText.length() > 0)
|
||||||
{
|
{
|
||||||
mText.erase(mText.length() - 1, mText.length());
|
mText.erase(mText.length() - 1, mText.length());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (state[SDL_SCANCODE_RETURN])
|
if (state[SDL_SCANCODE_RETURN])
|
||||||
{
|
{
|
||||||
std::string theCommand;
|
std::string theCommand;
|
||||||
|
|
|
@ -20,7 +20,7 @@ public:
|
||||||
|
|
||||||
void CancelChat();
|
void CancelChat();
|
||||||
void SetChatMode(std::string sChatMode);
|
void SetChatMode(std::string sChatMode);
|
||||||
void KeyEvent();
|
void KeyEvent(int iKeydown);
|
||||||
void KeyDown(int virtualKey, int scanCode);
|
void KeyDown(int virtualKey, int scanCode);
|
||||||
|
|
||||||
// Checks if a key was pushed since the chat window was opened.
|
// Checks if a key was pushed since the chat window was opened.
|
||||||
|
|
Loading…
Reference in a new issue