From a4f5952aedcf958ad91645bc80d651a069f9e1a8 Mon Sep 17 00:00:00 2001 From: yihuiyang Date: Mon, 6 Nov 2023 15:39:01 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DTextField=E6=97=A0=E6=B3=95?= =?UTF-8?q?=E8=BE=93=E5=85=A5=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: yihuiyang --- .../systemchannels/TextInputChannel.ets | 31 +++++++++++-------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/systemchannels/TextInputChannel.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/systemchannels/TextInputChannel.ets index 7e7d93c164..97697f6d73 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/systemchannels/TextInputChannel.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/systemchannels/TextInputChannel.ets @@ -40,24 +40,26 @@ export default class TextInputChannel { this.channel.invokeMethod("TextInputClient.requestExistingInputState", null); } - createEditingStateJSON(text: String, + createEditingStateJSON(text: string, selectionStart: number, selectionEnd: number, composingStart: number, - composingEnd: number): ESObject { - return new Map() - .set("text", text) - .set("selectionBase", selectionStart) - .set("selectionExtent", selectionEnd) - .set("composingBase", composingStart) - .set("composingExtent", composingEnd); + composingEnd: number): EditingState { + let state: EditingState = { + text: text, + selectionBase: selectionStart, + selectionExtent: selectionEnd, + composingBase: composingStart, + composingExtent: composingEnd + }; + return state; } /** * Instructs Flutter to update its text input editing state to reflect the given configuration. */ updateEditingState(inputClientId: number, - text: String, + text: string, selectionStart: number, selectionEnd: number, composingStart: number, @@ -67,8 +69,6 @@ export default class TextInputChannel { + selectionEnd + " Composing start: " + composingStart + " Composing end: " + composingEnd); const state: ESObject = this.createEditingStateJSON(text, selectionStart, selectionEnd, composingStart, composingEnd); this.channel.invokeMethod('TextInputClient.updateEditingState', [inputClientId, state]); - Log.d(TAG,"updateEditingState end"); - } newline(inputClientId: number): void { @@ -120,10 +120,15 @@ export default class TextInputChannel { } - - } +interface EditingState { + text: string; + selectionBase: number; + selectionExtent: number; + composingBase: number; + composingExtent: number; +} export interface TextInputMethodHandler { show(): void; -- Gitee