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 c499dacb3980aad684fed843d274e5aa4a8d9d6f..36c52b7faadaa9d8d6c439073f4b5bdd45926e58 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 {