Platform IME: add ImGuiPlatformImeData::WantVisible, hide IME when not used. (#2589)

docking
actboy168 3 years ago committed by ocornut
parent 1cbfe93520
commit 29a8ee0826

@ -61,6 +61,7 @@ Other Changes:
- Platform IME: changed io.ImeSetInputScreenPosFn() to io.SetPlatformImeDataFn() API, - Platform IME: changed io.ImeSetInputScreenPosFn() to io.SetPlatformImeDataFn() API,
now taking a ImGuiPlatformImeData structure which we can more easily extend in the future. now taking a ImGuiPlatformImeData structure which we can more easily extend in the future.
- Platform IME: moved io.ImeWindowHandle to GetMainViewport()->PlatformHandleRaw. - Platform IME: moved io.ImeWindowHandle to GetMainViewport()->PlatformHandleRaw.
- Platform IME: add ImGuiPlatformImeData::WantVisible, hide IME composition window when not used. (#2589) [@actboy168]
- Platform IME: [windows] call ImmSetCandidateWindow() to position candidate window. - Platform IME: [windows] call ImmSetCandidateWindow() to position candidate window.
- Backends: OpenGL3: Fixed a buffer overflow in imgui_impl_opengl3_loader.h init (added in 1.86). (#4468, #4830) [@dymk] - Backends: OpenGL3: Fixed a buffer overflow in imgui_impl_opengl3_loader.h init (added in 1.86). (#4468, #4830) [@dymk]
It would generally not have noticeable side-effect at runtime but would be detected by runtime checkers. It would generally not have noticeable side-effect at runtime but would be detected by runtime checkers.

@ -4149,6 +4149,7 @@ void ImGui::NewFrame()
// Platform IME data: reset for the frame // Platform IME data: reset for the frame
g.PlatformImeDataPrev = g.PlatformImeData; g.PlatformImeDataPrev = g.PlatformImeData;
g.PlatformImeData.WantVisible = false;
// Mouse wheel scrolling, scale // Mouse wheel scrolling, scale
UpdateMouseWheel(); UpdateMouseWheel();
@ -11510,6 +11511,8 @@ static void SetPlatformImeDataFn_DefaultImpl(ImGuiViewport* viewport, ImGuiPlatf
if (hwnd == 0) if (hwnd == 0)
return; return;
::ImmAssociateContextEx(hwnd, NULL, data->WantVisible ? IACE_DEFAULT : 0);
if (HIMC himc = ::ImmGetContext(hwnd)) if (HIMC himc = ::ImmGetContext(hwnd))
{ {
COMPOSITIONFORM composition_form = {}; COMPOSITIONFORM composition_form = {};

@ -2832,7 +2832,10 @@ struct ImGuiViewport
// (Optional) Support for IME (Input Method Editor) via the io.SetPlatformImeDataFn() function. // (Optional) Support for IME (Input Method Editor) via the io.SetPlatformImeDataFn() function.
struct ImGuiPlatformImeData struct ImGuiPlatformImeData
{ {
bool WantVisible; // A widget wants the IME to be visible
ImVec2 InputPos; // Position of the input cursor ImVec2 InputPos; // Position of the input cursor
ImGuiPlatformImeData() { memset(this, 0, sizeof(*this)); }
}; };
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------

@ -4760,7 +4760,10 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
// Notify OS of text input position for advanced IME (-1 x offset so that Windows IME can cover our cursor. Bit of an extra nicety.) // Notify OS of text input position for advanced IME (-1 x offset so that Windows IME can cover our cursor. Bit of an extra nicety.)
if (!is_readonly) if (!is_readonly)
{
g.PlatformImeData.WantVisible = true;
g.PlatformImeData.InputPos = ImVec2(cursor_screen_pos.x - 1.0f, cursor_screen_pos.y - g.FontSize); g.PlatformImeData.InputPos = ImVec2(cursor_screen_pos.x - 1.0f, cursor_screen_pos.y - g.FontSize);
}
} }
} }
else else

Loading…
Cancel
Save