mirror of
https://github.com/Drezil/imgui.git
synced 2024-12-18 14:16:36 +00:00
IO: changed AddInputCharacter(unsigned short c) signature to AddInputCharacter(unsigned int c).
Examples/Backends: Don't filter characters under 0x10000 before calling io.AddInputCharacter(), the filtering is done in io.AddInputCharacter() itself. This is in prevision for fuller Unicode support. (#2538, #2541)
This commit is contained in:
parent
7c256fbd40
commit
ef13d95466
@ -33,6 +33,7 @@ HOW TO UPDATE?
|
||||
-----------------------------------------------------------------------
|
||||
|
||||
Breaking Changes:
|
||||
- IO: changed AddInputCharacter(unsigned short c) signature to AddInputCharacter(unsigned int c).
|
||||
|
||||
Other Changes:
|
||||
- Columns: Fixed Separator from creating an extraneous draw command. (#125)
|
||||
@ -40,6 +41,9 @@ Other Changes:
|
||||
- Separator: Revert 1.70 "Declare its thickness (1.0f) to the layout" change. It's not incorrect
|
||||
but it breaks existing some layout patterns. Will return back to it when we expose Separator flags.
|
||||
- Scrollbar: Very minor bounding box adjustment to cope with various border size.
|
||||
- Examples/Backends: Don't filter characters under 0x10000 before calling io.AddInputCharacter(),
|
||||
the filtering is done in io.AddInputCharacter() itself. This is in prevision for fuller Unicode
|
||||
support. (#2538, #2541)
|
||||
|
||||
|
||||
-----------------------------------------------------------------------
|
||||
|
@ -15,6 +15,7 @@
|
||||
|
||||
// CHANGELOG
|
||||
// (minor and older changes stripped away, please see git history for details)
|
||||
// 2019-05-11: Inputs: Don't filter character value from ALLEGRO_EVENT_KEY_CHAR before calling AddInputCharacter().
|
||||
// 2019-04-30: Renderer: Added support for special ImDrawCallback_ResetRenderState callback to reset render state.
|
||||
// 2018-11-30: Platform: Added touchscreen support.
|
||||
// 2018-11-30: Misc: Setting up io.BackendPlatformName/io.BackendRendererName so they can be displayed in the About Window.
|
||||
@ -353,8 +354,7 @@ bool ImGui_ImplAllegro5_ProcessEvent(ALLEGRO_EVENT *ev)
|
||||
return true;
|
||||
case ALLEGRO_EVENT_KEY_CHAR:
|
||||
if (ev->keyboard.display == g_Display)
|
||||
if (ev->keyboard.unichar > 0 && ev->keyboard.unichar < 0x10000)
|
||||
io.AddInputCharacter((unsigned short)ev->keyboard.unichar);
|
||||
io.AddInputCharacter((unsigned int)ev->keyboard.unichar);
|
||||
return true;
|
||||
case ALLEGRO_EVENT_KEY_DOWN:
|
||||
case ALLEGRO_EVENT_KEY_UP:
|
||||
|
@ -15,6 +15,7 @@
|
||||
|
||||
// CHANGELOG
|
||||
// (minor and older changes stripped away, please see git history for details)
|
||||
// 2019-05-11: Inputs: Don't filter value from character callback before calling AddInputCharacter().
|
||||
// 2019-03-12: Misc: Preserve DisplayFramebufferScale when main window is minimized.
|
||||
// 2018-11-30: Misc: Setting up io.BackendPlatformName so it can be displayed in the About Window.
|
||||
// 2018-11-07: Inputs: When installing our GLFW callbacks, we save user's previously installed ones - if any - and chain call them.
|
||||
@ -120,8 +121,7 @@ void ImGui_ImplGlfw_CharCallback(GLFWwindow* window, unsigned int c)
|
||||
g_PrevUserCallbackChar(window, c);
|
||||
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
if (c > 0 && c < 0x10000)
|
||||
io.AddInputCharacter((unsigned short)c);
|
||||
io.AddInputCharacter(c);
|
||||
}
|
||||
|
||||
static bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks, GlfwClientApi client_api)
|
||||
|
@ -118,7 +118,7 @@ void ImGui_ImplGLUT_KeyboardFunc(unsigned char c, int x, int y)
|
||||
//printf("char_down_func %d '%c'\n", c, c);
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
if (c >= 32)
|
||||
io.AddInputCharacter((unsigned short)c);
|
||||
io.AddInputCharacter((unsigned int)c);
|
||||
|
||||
// Store letters in KeysDown[] array as both uppercase and lowercase + Handle GLUT translating CTRL+A..CTRL+Z as 1..26.
|
||||
// This is a hacky mess but GLUT is unable to distinguish e.g. a TAB key from CTRL+I so this is probably the best we can do here.
|
||||
|
@ -12,6 +12,7 @@
|
||||
|
||||
// CHANGELOG
|
||||
// (minor and older changes stripped away, please see git history for details)
|
||||
// 2019-05-11: Inputs: Don't filter value from character callback before calling AddInputCharacter().
|
||||
// 2018-11-30: Misc: Setting up io.BackendPlatformName/io.BackendRendererName so they can be displayed in the About Window.
|
||||
// 2018-02-16: Misc: Obsoleted the io.RenderDrawListsFn callback and exposed ImGui_Marmalade_RenderDrawData() in the .h file so you can call it yourself.
|
||||
// 2018-02-06: Misc: Removed call to ImGui::Shutdown() which is not available from 1.60 WIP, user needs to call CreateContext/DestroyContext themselves.
|
||||
@ -166,8 +167,7 @@ int32 ImGui_Marmalade_CharCallback(void* system_data, void* user_data)
|
||||
{
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
s3eKeyboardCharEvent* e = (s3eKeyboardCharEvent*)system_data;
|
||||
if ((e->m_Char > 0 && e->m_Char < 0x10000))
|
||||
io.AddInputCharacter((unsigned short)e->m_Char);
|
||||
io.AddInputCharacter((unsigned int)e->m_Char);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -12,6 +12,7 @@
|
||||
|
||||
// CHANGELOG
|
||||
// (minor and older changes stripped away, please see git history for details)
|
||||
// 2019-05-11: Inputs: Don't filter character values before calling AddInputCharacter() apart from 0xF700..0xFFFF range.
|
||||
// 2018-11-30: Misc: Setting up io.BackendPlatformName so it can be displayed in the About Window.
|
||||
// 2018-07-07: Initial version.
|
||||
|
||||
@ -189,8 +190,8 @@ bool ImGui_ImplOSX_HandleEvent(NSEvent* event, NSView* view)
|
||||
for (int i = 0; i < len; i++)
|
||||
{
|
||||
int c = [str characterAtIndex:i];
|
||||
if (c < 0xF700 && !io.KeyCtrl)
|
||||
io.AddInputCharacter((unsigned short)c);
|
||||
if (!io.KeyCtrl && !(c >= 0xF700 && c <= 0xFFFF))
|
||||
io.AddInputCharacter((unsigned int)c);
|
||||
|
||||
// We must reset in case we're pressing a sequence of special keys while keeping the command pressed
|
||||
int key = mapCharacterToKey(c);
|
||||
|
@ -18,6 +18,7 @@
|
||||
|
||||
// CHANGELOG
|
||||
// (minor and older changes stripped away, please see git history for details)
|
||||
// 2019-05-11: Inputs: Don't filter value from WM_CHAR before calling AddInputCharacter().
|
||||
// 2019-01-17: Misc: Using GetForegroundWindow()+IsChild() instead of GetActiveWindow() to be compatible with windows created in a different thread or parent.
|
||||
// 2019-01-17: Inputs: Added support for mouse buttons 4 and 5 via WM_XBUTTON* messages.
|
||||
// 2019-01-15: Inputs: Added support for XInput gamepads (if ImGuiConfigFlags_NavEnableGamepad is set by user application).
|
||||
@ -305,8 +306,7 @@ IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hwnd, UINT msg, WPARA
|
||||
return 0;
|
||||
case WM_CHAR:
|
||||
// You can also use ToAscii()+GetKeyboardState() to retrieve characters.
|
||||
if (wParam > 0 && wParam < 0x10000)
|
||||
io.AddInputCharacter((unsigned short)wParam);
|
||||
io.AddInputCharacter((unsigned int)wParam);
|
||||
return 0;
|
||||
case WM_SETCURSOR:
|
||||
if (LOWORD(lParam) == HTCLIENT && ImGui_ImplWin32_UpdateMouseCursor())
|
||||
|
@ -369,6 +369,7 @@ CODE
|
||||
When you are not sure about a old symbol or function name, try using the Search/Find function of your IDE to look for comments or references in all imgui files.
|
||||
You can read releases logs https://github.com/ocornut/imgui/releases for more details.
|
||||
|
||||
- 2019/05/11 (1.71) - changed io.AddInputCharacter(unsigned short c) signature to io.AddInputCharacter(unsigned int c).
|
||||
- 2019/04/29 (1.70) - improved ImDrawList thick strokes (>1.0f) preserving correct thickness up to 90 degrees angles (e.g. rectangles). If you have custom rendering using thick lines, they will appear thicker now.
|
||||
- 2019/04/29 (1.70) - removed GetContentRegionAvailWidth(), use GetContentRegionAvail().x instead. Kept inline redirection function (will obsolete).
|
||||
- 2019/03/04 (1.69) - renamed GetOverlayDrawList() to GetForegroundDrawList(). Kept redirection function (will obsolete).
|
||||
@ -1251,9 +1252,10 @@ ImGuiIO::ImGuiIO()
|
||||
// Pass in translated ASCII characters for text input.
|
||||
// - with glfw you can get those from the callback set in glfwSetCharCallback()
|
||||
// - on Windows you can get those using ToAscii+keyboard state, or via the WM_CHAR message
|
||||
void ImGuiIO::AddInputCharacter(ImWchar c)
|
||||
void ImGuiIO::AddInputCharacter(unsigned int c)
|
||||
{
|
||||
InputQueueCharacters.push_back(c);
|
||||
if (c > 0 && c < 0x10000)
|
||||
InputQueueCharacters.push_back((ImWchar)c);
|
||||
}
|
||||
|
||||
void ImGuiIO::AddInputCharactersUTF8(const char* utf8_chars)
|
||||
@ -1262,7 +1264,7 @@ void ImGuiIO::AddInputCharactersUTF8(const char* utf8_chars)
|
||||
{
|
||||
unsigned int c = 0;
|
||||
utf8_chars += ImTextCharFromUtf8(&c, utf8_chars, NULL);
|
||||
if (c > 0 && c <= 0xFFFF)
|
||||
if (c > 0 && c < 0x10000)
|
||||
InputQueueCharacters.push_back((ImWchar)c);
|
||||
}
|
||||
}
|
||||
|
2
imgui.h
2
imgui.h
@ -1402,7 +1402,7 @@ struct ImGuiIO
|
||||
float NavInputs[ImGuiNavInput_COUNT]; // Gamepad inputs. Cleared back to zero by EndFrame(). Keyboard keys will be auto-mapped and be written here by NewFrame().
|
||||
|
||||
// Functions
|
||||
IMGUI_API void AddInputCharacter(ImWchar c); // Queue new character input
|
||||
IMGUI_API void AddInputCharacter(unsigned int c); // Queue new character input
|
||||
IMGUI_API void AddInputCharactersUTF8(const char* str); // Queue new characters input from an UTF-8 string
|
||||
IMGUI_API void ClearInputCharacters(); // Clear the text input buffer manually
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user