From a3aaaa1efbd1d78ff916b4afc27297fe238317cc Mon Sep 17 00:00:00 2001 From: pagedown Date: Wed, 26 Jan 2022 18:21:20 +0800 Subject: [PATCH] macOS: Explicitly cancel IME composition when losing the focus --- glfw/cocoa_window.m | 1 + 1 file changed, 1 insertion(+) diff --git a/glfw/cocoa_window.m b/glfw/cocoa_window.m index b6fe6ef58..092d83df6 100644 --- a/glfw/cocoa_window.m +++ b/glfw/cocoa_window.m @@ -709,6 +709,7 @@ static const NSRange kEmptyRange = { NSNotFound, 0 }; _glfwInputWindowFocus(window, false); // IME is cancelled when losing the focus if ([window->ns.view hasMarkedText]) { + [[window->ns.view inputContext] discardMarkedText]; [window->ns.view unmarkText]; GLFWkeyevent dummy = {.action = GLFW_RELEASE, .ime_state = GLFW_IME_PREEDIT_CHANGED}; _glfwInputKeyboard(window, &dummy);