mirror of
https://github.com/Drezil/imgui.git
synced 2024-12-17 21:56:36 +00:00
AddInputCharactersUTF8: shallow tweaks (#274)
This commit is contained in:
parent
bc4ede656b
commit
d6117e33d0
14
imgui.cpp
14
imgui.cpp
@ -778,16 +778,14 @@ void ImGuiIO::AddInputCharacter(ImWchar c)
|
||||
}
|
||||
}
|
||||
|
||||
void ImGuiIO::AddInputCharactersUTF8(const char* utf8chars)
|
||||
void ImGuiIO::AddInputCharactersUTF8(const char* utf8_chars)
|
||||
{
|
||||
// we can't pass more wchars than ImGuiIO::InputCharacters[] can hold so don't convert more
|
||||
static const int wcharBufLen = sizeof(ImGuiIO::InputCharacters)/sizeof(ImWchar);
|
||||
ImWchar wchars[wcharBufLen];
|
||||
ImTextStrFromUtf8(wchars, wcharBufLen, utf8chars, NULL);
|
||||
for(int i=0; i<wcharBufLen && wchars[i] != 0; ++i)
|
||||
{
|
||||
// We can't pass more wchars than ImGuiIO::InputCharacters[] can hold so don't convert more
|
||||
const int wchars_buf_len = sizeof(ImGuiIO::InputCharacters) / sizeof(ImWchar);
|
||||
ImWchar wchars[wchars_buf_len];
|
||||
ImTextStrFromUtf8(wchars, wchars_buf_len, utf8_chars, NULL);
|
||||
for (int i = 0; wchars[i] != 0 && i < wchars_buf_len; i++)
|
||||
AddInputCharacter(wchars[i]);
|
||||
}
|
||||
}
|
||||
|
||||
// Math bits
|
||||
|
6
imgui.h
6
imgui.h
@ -703,9 +703,9 @@ struct ImGuiIO
|
||||
bool KeysDown[512]; // Keyboard keys that are pressed (in whatever storage order you naturally have access to keyboard data)
|
||||
ImWchar InputCharacters[16+1]; // List of characters input (translated by user from keypress+keyboard state). Fill using AddInputCharacter() helper.
|
||||
|
||||
// Function
|
||||
IMGUI_API void AddInputCharacter(ImWchar c); // Helper to add a new character into InputCharacters[]
|
||||
IMGUI_API void AddInputCharactersUTF8(const char* utf8chars); // Helper to add new characters into InputCharacters[] from an utf8-string
|
||||
// Functions
|
||||
IMGUI_API void AddInputCharacter(ImWchar c); // Helper to add a new character into InputCharacters[]
|
||||
IMGUI_API void AddInputCharactersUTF8(const char* utf8_chars); // Helper to add new characters into InputCharacters[] from an UTF-8 string
|
||||
|
||||
//------------------------------------------------------------------
|
||||
// Output - Retrieve after calling NewFrame(), you can use them to discard inputs or hide them from the rest of your application
|
||||
|
Loading…
Reference in New Issue
Block a user