Fix minor text input problem related to dead key previewing.

macOS normally previews a dead key and then replaces the preview by the final text
after the second key is typed.
macOS ≥10.7 also opens an auxiliary window to help choosing among possible characters
after some keys (e.g., n, c, o, a) are pressed and maintained for a while.
The problem fixed here is that after an auxiliary window has been used,
dead keys are no longer previewed.
That problem emerged at some undetermined point before 10.14 and after 10.7.
This commit is contained in:
ManoloFLTK 2019-01-24 15:19:33 +01:00
parent 4f8e07a0cd
commit 9b272cfa4e

View File

@ -2646,6 +2646,13 @@ static FLTextInputContext* fltextinputcontext_instance = nil;
received,strlen([received UTF8String]),Fl::compose_state,replacementRange.location,replacementRange.length);*/
fl_lock_function();
Fl_Window *target = [(FLWindow*)[self window] getFl_Window];
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
if (fl_mac_os_version >= 101400 && replacementRange.length > 0) {
// occurs after a key was pressed and maintained and an auxiliary window appeared
// prevents marking dead key from deactivation
[[self inputContext] discardMarkedText];
}
#endif
while (replacementRange.length--) { // delete replacementRange.length characters before insertion point
int saved_keysym = Fl::e_keysym;
Fl::e_keysym = FL_BackSpace;