From 5d12789e71e8358266b99a7bb53f6042f229b3dd Mon Sep 17 00:00:00 2001 From: laoguanyao <806103474@qq.com> Date: Mon, 7 Oct 2024 16:26:42 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9B=9E=E9=80=80PR416=E7=9A=84=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=20=E5=A2=9E=E5=8A=A0InputMethod=E7=9A=84detach?= =?UTF-8?q?=E6=96=B9=E6=B3=95=EF=BC=8C=E4=BF=9D=E8=AF=81=E9=87=8D=E6=96=B0?= =?UTF-8?q?=E6=8B=89=E8=B5=B7=E8=BD=AF=E9=94=AE=E7=9B=98=E5=8F=AF=E6=AD=A3?= =?UTF-8?q?=E5=B8=B8=E5=88=9D=E5=A7=8B=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: laoguanyao <806103474@qq.com> --- .../ets/plugin/editing/TextInputPlugin.ets | 32 +------------------ 1 file changed, 1 insertion(+), 31 deletions(-) diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/editing/TextInputPlugin.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/editing/TextInputPlugin.ets index c499dacb39..36c52b7faa 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/editing/TextInputPlugin.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/editing/TextInputPlugin.ets @@ -17,17 +17,11 @@ import TextInputChannel, { Configuration, TextEditState, TextInputMethodHandler, - TextInputType } from '../../embedding/engine/systemchannels/TextInputChannel'; import inputMethod from '@ohos.inputMethod'; import Log from '../../util/Log'; import { EditingStateWatcher, ListenableEditingState } from './ListenableEditingState'; import Any from '../common/Any'; -import { window } from '@kit.ArkUI'; -import FlutterManager from '../../embedding/ohos/FlutterManager'; -import { IntentionCode } from '@ohos.multimodalInput.intentionCode'; -import {KeyCode} from '@kit.InputKit'; -import { BusinessError } from '@kit.BasicServicesKit'; /// 临时规避缺少newline对应枚举问题 const NEWLINE_KEY_TYPE: number = 8; @@ -273,37 +267,12 @@ class TextInputMethodHandlerImpl implements TextInputMethodHandler { this.imcFlag = true; } - sendKeyboardEvent(type: KeyType, keyCode: number): void { - let event: KeyEvent = { - type: type, - keyCode: keyCode, - keyText: '', - keySource: KeySource.Keyboard, - deviceId: 0, - metaKey: 0, - timestamp: 0, - stopPropagation: (): void => { - throw new Error('Function not implemented.'); - }, - intentionCode: IntentionCode.INTENTION_BACK - } - FlutterManager.getInstance().getFlutterViewList().forEach((value) => { - value.onKeyEvent(event) - }) - } - private insertTextCallback = (text: string) => { Log.d(TextInputMethodHandlerImpl.TAG, "insertText: " + text); this.mEditable.handleInsertTextEvent(text); } private deleteLeftCallback = (length: number) => { - /// 暂时规避方案 - /// OS机制与Android不一致,需要去监听软键盘事件才能发送KeyEvent事件 - if (this.mEditable.getStringCache() == "") { - this.sendKeyboardEvent(KeyType.Down, KeyCode.KEYCODE_DEL) - this.sendKeyboardEvent(KeyType.Up, KeyCode.KEYCODE_DEL) - } this.mEditable.handleDeleteEvent(false, length); } @@ -340,6 +309,7 @@ class TextInputMethodHandlerImpl implements TextInputMethodHandler { this.inputMethodController.off('sendKeyboardStatus', this.sendKeyboardStatusCallback); this.inputMethodController.off('selectByRange', this.selectByRangeCallback); this.imcFlag = false; + this.inputMethodController.detach() } public clearTextInputClient(): void { -- Gitee