From 0d3243e6dd07aca3e770b78cb1cbc90ae6eda3ab Mon Sep 17 00:00:00 2001 From: fufesou <13586388+fufesou@users.noreply.github.com> Date: Fri, 18 Oct 2024 08:55:18 +0800 Subject: [PATCH] fix: android, Korean input (#9667) Signed-off-by: fufesou --- flutter/lib/mobile/pages/remote_page.dart | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/flutter/lib/mobile/pages/remote_page.dart b/flutter/lib/mobile/pages/remote_page.dart index 0072a2608..395ce3333 100644 --- a/flutter/lib/mobile/pages/remote_page.dart +++ b/flutter/lib/mobile/pages/remote_page.dart @@ -57,6 +57,9 @@ class _RemotePageState extends State { final TextEditingController _textController = TextEditingController(text: initText); + // This timer is used to check the composing status of the soft keyboard. + // It is used for Android, Korean(and other similar) input method. + Timer? _composingTimer; _RemotePageState(String id) { initSharedStates(id); @@ -104,6 +107,7 @@ class _RemotePageState extends State { _physicalFocusNode.dispose(); await gFFI.close(); _timer?.cancel(); + _composingTimer?.cancel(); gFFI.dialogManager.dismissAll(); await SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: SystemUiOverlay.values); @@ -139,6 +143,7 @@ class _RemotePageState extends State { gFFI.ffiModel.pi.version.isNotEmpty) { gFFI.invokeMethod("enable_soft_keyboard", false); } + _composingTimer?.cancel(); } else { _timer?.cancel(); _timer = Timer(kMobileDelaySoftKeyboardFocus, () { @@ -202,6 +207,13 @@ class _RemotePageState extends State { } void _handleNonIOSSoftKeyboardInput(String newValue) { + _composingTimer?.cancel(); + if (_textController.value.isComposingRangeValid) { + _composingTimer = Timer(Duration(milliseconds: 25), () { + _handleNonIOSSoftKeyboardInput(_textController.value.text); + }); + return; + } var oldValue = _value; _value = newValue; if (oldValue.isNotEmpty &&