Platform: Fix space not generating a text event

This commit is contained in:
Jérôme Leclercq 2020-11-17 17:43:42 +01:00
parent af55ecc2a5
commit 7526923a8d
1 changed files with 9 additions and 5 deletions

View File

@ -2,8 +2,6 @@
// This file is part of the "Nazara Engine - Platform module" // This file is part of the "Nazara Engine - Platform module"
// For conditions of distribution and use, see copyright notice in Config.hpp // For conditions of distribution and use, see copyright notice in Config.hpp
#include <cstdio>
#include <memory>
#include <Nazara/Core/ConditionVariable.hpp> #include <Nazara/Core/ConditionVariable.hpp>
#include <Nazara/Core/Error.hpp> #include <Nazara/Core/Error.hpp>
#include <Nazara/Core/ErrorFlags.hpp> #include <Nazara/Core/ErrorFlags.hpp>
@ -19,6 +17,9 @@
#include <Nazara/Utility/Image.hpp> #include <Nazara/Utility/Image.hpp>
#include <SDL2/SDL.h> #include <SDL2/SDL.h>
#include <SDL2/SDL_syswm.h> #include <SDL2/SDL_syswm.h>
#include <Utfcpp/utf8.h>
#include <cstdio>
#include <memory>
namespace Nz namespace Nz
{ {
@ -488,23 +489,26 @@ namespace Nz
break; break;
case SDL_TEXTINPUT: case SDL_TEXTINPUT:
{
if (SDL_GetWindowID(window->m_handle) != event->text.windowID) if (SDL_GetWindowID(window->m_handle) != event->text.windowID)
return 0; return 0;
evt.type = WindowEventType_TextEntered; evt.type = WindowEventType_TextEntered;
evt.text.repeated = false; evt.text.repeated = false;
for (decltype(evt.text.character) codepoint : String::Unicode(event->text.text).Simplify().GetUtf32String()) utf8::unchecked::iterator<const char*> it(event->text.text);
do
{ {
evt.text.character = codepoint; evt.text.character = *it;
window->m_parent->PushEvent(evt); window->m_parent->PushEvent(evt);
} } while (*it++);
// prevent post switch event // prevent post switch event
evt.type = WindowEventType::WindowEventType_Max; evt.type = WindowEventType::WindowEventType_Max;
break; break;
}
case SDL_TEXTEDITING: case SDL_TEXTEDITING:
if (SDL_GetWindowID(window->m_handle) != event->edit.windowID) if (SDL_GetWindowID(window->m_handle) != event->edit.windowID)