mirror of
https://github.com/glfw/glfw
synced 2026-09-26 16:18:21 +03:00
Cocoa: Bypass text input system when unfocused
When explicit text input focus is inactive, skip interpretKeyEvents and send plain event characters through GLFW text input instead. This prevents routing key events through NSTextInput composition while preserving normal key input. Applications that never call glfwSetTextInputFocus keep the previous interpretKeyEvents behavior. On focus out, discard marked text through the existing NSTextInputContext reset path. Do not use TIS input source switching for this API. This builds on the Cocoa input method work from clear-code/glfw#7.
This commit is contained in:
parent
a8819c7924
commit
148ff80572
2 changed files with 11 additions and 2 deletions
|
|
@ -89,6 +89,7 @@ video tutorials.
|
|||
- GeO4d
|
||||
- Marcus Geelnard
|
||||
- Gegy
|
||||
- ghostflyby
|
||||
- ghuser404
|
||||
- Charles Giessen
|
||||
- Ryan C. Gordon
|
||||
|
|
|
|||
|
|
@ -573,7 +573,14 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
|
|||
if (![self hasMarkedText])
|
||||
_glfwInputKey(window, key, [event keyCode], GLFW_PRESS, mods);
|
||||
|
||||
[self interpretKeyEvents:@[event]];
|
||||
if (!window->textInputFocusInitialized || window->textInputFocus)
|
||||
[self interpretKeyEvents:@[event]];
|
||||
else
|
||||
{
|
||||
NSString* characters = [event characters];
|
||||
if (characters)
|
||||
[self insertText:characters replacementRange:[self selectedRange]];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)flagsChanged:(NSEvent *)event
|
||||
|
|
@ -2039,7 +2046,8 @@ void _glfwResetPreeditTextCocoa(_GLFWwindow* window)
|
|||
|
||||
void _glfwSetTextInputFocusCocoa(_GLFWwindow* window, GLFWbool focused)
|
||||
{
|
||||
// TODO: Add a safe NSTextInputContext mapping without changing TIS behavior.
|
||||
if (!focused)
|
||||
_glfwResetPreeditTextCocoa(window);
|
||||
}
|
||||
|
||||
void _glfwSetIMEStatusCocoa(_GLFWwindow* window, int active)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue