Fix text input when not in edit box mode, fix backtick handling

This commit is contained in:
Jonathan G Rennison
2019-10-08 02:28:09 +01:00
parent 5d1578bb7f
commit 34a6f3c72a

View File

@@ -478,6 +478,7 @@ static uint ConvertSdlKeyIntoMy(SDL_Keysym *sym, WChar *character)
#else #else
if (sym->scancode == 49) key = WKC_BACKQUOTE; if (sym->scancode == 49) key = WKC_BACKQUOTE;
#endif #endif
if (sym->scancode == SDL_SCANCODE_GRAVE) key = WKC_BACKQUOTE;
/* META are the command keys on mac */ /* META are the command keys on mac */
if (sym->mod & KMOD_GUI) key |= WKC_META; if (sym->mod & KMOD_GUI) key |= WKC_META;
@@ -601,14 +602,16 @@ int VideoDriver_SDL::PollEvent()
keycode & WKC_CTRL || keycode & WKC_CTRL ||
keycode & WKC_ALT || keycode & WKC_ALT ||
(keycode >= WKC_F1 && keycode <= WKC_F12) || (keycode >= WKC_F1 && keycode <= WKC_F12) ||
!IsValidChar(character, CS_ALPHANUMERAL)) { !IsValidChar(character, CS_ALPHANUMERAL) ||
!this->edit_box_focused) {
HandleKeypress(keycode, character); HandleKeypress(keycode, character);
} }
} }
break; break;
case SDL_TEXTINPUT: { case SDL_TEXTINPUT: {
if (EditBoxInGlobalFocus()) { if (EditBoxInGlobalFocus() && !(_focused_window->window_class == WC_CONSOLE &&
ConvertSdlKeycodeIntoMy(SDL_GetKeyFromName(ev.text.text)) == WKC_BACKQUOTE)) {
HandleTextInput(nullptr, true); HandleTextInput(nullptr, true);
HandleTextInput(ev.text.text); HandleTextInput(ev.text.text);
SetTextInputRect(); SetTextInputRect();
@@ -684,6 +687,9 @@ const char *VideoDriver_SDL::Start(const char * const *parm)
_draw_threaded = GetDriverParam(parm, "no_threads") == nullptr && GetDriverParam(parm, "no_thread") == nullptr; _draw_threaded = GetDriverParam(parm, "no_threads") == nullptr && GetDriverParam(parm, "no_thread") == nullptr;
SDL_StopTextInput();
this->edit_box_focused = false;
return nullptr; return nullptr;
} }