Platform IME: changed io.ImeSetInputScreenPosFn() to io.SetPlatformImeDataFn() API.

Ref #2589, #2598, #3108, #3113, #3653, #4642
This commit is contained in:
ocornut
2022-01-05 13:03:48 +01:00
parent 04bc0b0bb8
commit 3a90dc3893
7 changed files with 68 additions and 26 deletions

View File

@ -246,8 +246,10 @@ static bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks, Glfw
io.SetClipboardTextFn = ImGui_ImplGlfw_SetClipboardText;
io.GetClipboardTextFn = ImGui_ImplGlfw_GetClipboardText;
io.ClipboardUserData = bd->Window;
// Set platform dependent data in viewport
#if defined(_WIN32)
io.ImeWindowHandle = (void*)glfwGetWin32Window(bd->Window);
ImGui::GetMainViewport()->PlatformHandleRaw = (void*)glfwGetWin32Window(bd->Window);
#endif
// Create mouse cursors

View File

@ -230,11 +230,12 @@ static bool ImGui_ImplSDL2_Init(SDL_Window* window)
bd->MouseCursors[ImGuiMouseCursor_Hand] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_HAND);
bd->MouseCursors[ImGuiMouseCursor_NotAllowed] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_NO);
// Set platform dependent data in viewport
#ifdef _WIN32
SDL_SysWMinfo info;
SDL_VERSION(&info.version);
if (SDL_GetWindowWMInfo(window, &info))
io.ImeWindowHandle = info.info.win.window;
ImGui::GetMainViewport()->PlatformHandleRaw = (void*)info.info.win.window;
#else
(void)window;
#endif

View File

@ -122,7 +122,8 @@ bool ImGui_ImplWin32_Init(void* hwnd)
bd->Time = perf_counter;
bd->LastMouseCursor = ImGuiMouseCursor_COUNT;
io.ImeWindowHandle = hwnd;
// Set platform dependent data in viewport
ImGui::GetMainViewport()->PlatformHandleRaw = (void*)hwnd;
// Keyboard mapping. Dear ImGui will use those indices to peek into the io.KeysDown[] array that we will update during the application lifetime.
io.KeyMap[ImGuiKey_Tab] = VK_TAB;