AddInputCharacter can handle Unicode

This commit is contained in:
Cloud Wu 2019-05-10 16:01:45 +08:00
parent ce9ecaa6e4
commit af31aaaa4c
2 changed files with 3 additions and 10 deletions

View File

@ -9,7 +9,6 @@
#include <bx/math.h>
#include <bx/timer.h>
#include <dear-imgui/imgui.h>
#include <dear-imgui/imgui_internal.h>
#include "imgui.h"
#include "../bgfx_utils.h"
@ -348,15 +347,9 @@ struct OcornutImguiContext
m_viewId = _viewId;
ImGuiIO& io = ImGui::GetIO();
if (_inputChar < 0x7f)
if (_inputChar >= 0)
{
io.AddInputCharacter(_inputChar); // ASCII or GTFO! :(
} else
{
char tmpstr[6];
ImWchar unicode[2] = { (ImWchar)_inputChar, 0 };
ImTextStrToUtf8(tmpstr, sizeof(tmpstr), unicode, unicode+1);
io.AddInputCharactersUTF8(tmpstr);
io.AddInputCharacter(_inputChar);
}
io.DisplaySize = ImVec2( (float)_width, (float)_height);

View File

@ -30,7 +30,7 @@ namespace bx { struct AllocatorI; }
void imguiCreate(float _fontSize = 18.0f, bx::AllocatorI* _allocator = NULL);
void imguiDestroy();
void imguiBeginFrame(int32_t _mx, int32_t _my, uint8_t _button, int32_t _scroll, uint16_t _width, uint16_t _height, int _inputChar = 0, bgfx::ViewId _view = 255);
void imguiBeginFrame(int32_t _mx, int32_t _my, uint8_t _button, int32_t _scroll, uint16_t _width, uint16_t _height, int _inputChar = -1, bgfx::ViewId _view = 255);
void imguiEndFrame();
namespace entry { class AppI; }