From 8c9654f379a3f56cf21ff9bacacb90fa6aa6b1df Mon Sep 17 00:00:00 2001 From: lwtt <1377477209@qq.com> Date: Wed, 29 Nov 2023 15:45:38 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9textInputChannel=20?= =?UTF-8?q?=E8=AF=AD=E6=B3=95=E9=97=AE=E9=A2=98=E5=AF=BC=E8=87=B4=E7=BC=96?= =?UTF-8?q?har=E6=97=B6=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: lwtt <1377477209@qq.com> --- .../ets/embedding/engine/systemchannels/TextInputChannel.ets | 2 +- .../src/main/ets/plugin/editing/ListenableEditingState.ets | 2 ++ .../flutter/src/main/ets/plugin/editing/TextInputPlugin.ets | 2 +- 3 files changed, 4 insertions(+), 2 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 64de036552..b077d6b0fa 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 @@ -231,7 +231,7 @@ export class Configuration { throw new Error("Configuration JSON missing 'inputAction' property."); } - let fields:Array = null; + let fields:Array = new Array(); if (json.fields !== null && json.fields !== undefined) { fields = json.fields.map((field:ESObject):ESObject => Configuration.fromJson(field)); } diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/editing/ListenableEditingState.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/editing/ListenableEditingState.ets index cac4a34cb7..ab3be30cab 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/editing/ListenableEditingState.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/editing/ListenableEditingState.ets @@ -240,6 +240,8 @@ export class ListenableEditingState { } handleFunctionKey(functionKey: inputMethod.FunctionKey): void { + if(!this.TextInputChannel) + return switch (functionKey.enterKeyType) { case inputMethod.EnterKeyType.PREVIOUS: this.TextInputChannel.previous(this.client); 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 5a47a5062c..dcb153268c 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 @@ -76,7 +76,7 @@ class TextInputMethodHandlerImpl implements TextInputMethodHandler { enterKeyType: 1 }}; this.plugin = plugin; - this.mEditable = new ListenableEditingState(null , 0); + this.mEditable = new ListenableEditingState(null as ESObject, 0); this.inputMethodController = inputMethod.getController(); this.inputTarget = new InputTarget(Type.NO_TARGET, 0); } -- Gitee From 875e2af2b81b928e1b7561dfccdb9b7ce77e86f4 Mon Sep 17 00:00:00 2001 From: lwtt <1377477209@qq.com> Date: Wed, 29 Nov 2023 17:23:55 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9textInputChannel=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=97=A0=E6=B3=95=E8=A7=A6=E5=8F=91onsubmit?= =?UTF-8?q?=20,=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: lwtt <1377477209@qq.com> --- .../src/main/ets/plugin/editing/ListenableEditingState.ets | 6 ++++-- .../flutter/src/main/ets/plugin/editing/TextInputPlugin.ets | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/editing/ListenableEditingState.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/editing/ListenableEditingState.ets index ab3be30cab..6396d2520e 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/editing/ListenableEditingState.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/plugin/editing/ListenableEditingState.ets @@ -22,7 +22,7 @@ import TextInputChannel from '../../embedding/engine/systemchannels/TextInputCha const TAG = "ListenableEditingState"; export class ListenableEditingState { - private TextInputChannel: TextInputChannel|null = null ; + private TextInputChannel: TextInputChannel | null = null ; private client: number = 0 //Cache used to storage software keyboard input action private mStringCache: string; @@ -45,7 +45,7 @@ export class ListenableEditingState { private mComposingEndWhenBeginBatchEdit: number = 0; - constructor(TextInputChannel:TextInputChannel,client:number) { + constructor(TextInputChannel:TextInputChannel | null,client:number) { this.TextInputChannel = TextInputChannel; this.client = client this.mStringCache = ""; @@ -241,7 +241,9 @@ export class ListenableEditingState { handleFunctionKey(functionKey: inputMethod.FunctionKey): void { if(!this.TextInputChannel) + { return + } switch (functionKey.enterKeyType) { case inputMethod.EnterKeyType.PREVIOUS: this.TextInputChannel.previous(this.client); 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 dcb153268c..f29018808a 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 @@ -76,7 +76,7 @@ class TextInputMethodHandlerImpl implements TextInputMethodHandler { enterKeyType: 1 }}; this.plugin = plugin; - this.mEditable = new ListenableEditingState(null as ESObject, 0); + this.mEditable = new ListenableEditingState(null, 0); this.inputMethodController = inputMethod.getController(); this.inputTarget = new InputTarget(Type.NO_TARGET, 0); } -- Gitee