diff --git a/glfw/cocoa_window.m b/glfw/cocoa_window.m index 97ee504b6..01badaf4e 100644 --- a/glfw/cocoa_window.m +++ b/glfw/cocoa_window.m @@ -864,6 +864,12 @@ static const NSRange kEmptyRange = { NSNotFound, 0 }; showCursor(window); _glfwInputWindowFocus(window, false); + // IME is cancelled when losing the focus + if ([window->ns.view hasMarkedText]) { + [window->ns.view unmarkText]; + GLFWkeyevent dummy = {.action = GLFW_RELEASE, .ime_state = GLFW_IME_PREEDIT_CHANGED}; + _glfwInputKeyboard(window, &dummy); + } } - (void)windowDidChangeScreen:(NSNotification *)notification