From 2eb6e8c81f8bbabe49a8b38cc9666bc5cc0771fb Mon Sep 17 00:00:00 2001 From: xujie Date: Tue, 18 Apr 2023 18:55:13 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0OnTextChangedListener?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: xujie --- .../on_text_changed_listener_impl.cpp | 12 ++++++++---- .../text_field/on_text_changed_listener_impl.h | 3 ++- .../on_text_changed_listener_impl.cpp | 17 +++++++++++------ .../text_field/on_text_changed_listener_impl.h | 3 ++- 4 files changed, 23 insertions(+), 12 deletions(-) diff --git a/frameworks/core/components/text_field/on_text_changed_listener_impl.cpp b/frameworks/core/components/text_field/on_text_changed_listener_impl.cpp index ada988cdc13..c26c2454ee5 100644 --- a/frameworks/core/components/text_field/on_text_changed_listener_impl.cpp +++ b/frameworks/core/components/text_field/on_text_changed_listener_impl.cpp @@ -129,10 +129,14 @@ void OnTextChangedListenerImpl::SetKeyboardStatus(bool status) void OnTextChangedListenerImpl::SendKeyEventFromInputMethod(const MiscServices::KeyEvent& event) {} -void OnTextChangedListenerImpl::SendKeyboardInfo(const MiscServices::KeyboardInfo& info) +void OnTextChangedListenerImpl::SendKeyboardStatus(const MiscServices::KeyboardStatus& keyboardStatus) { - HandleKeyboardStatus(info.GetKeyboardStatus()); - HandleFunctionKey(info.GetFunctionKey()); + HandleKeyboardStatus(keyboardStatus); +} + +void OnTextChangedListenerImpl::SendFunctionKey(const MiscServices::FunctionKey& functionKey) +{ + HandleFunctionKey(functionKey); } void OnTextChangedListenerImpl::HandleKeyboardStatus(MiscServices::KeyboardStatus status) @@ -153,7 +157,7 @@ void OnTextChangedListenerImpl::HandleFunctionKey(MiscServices::FunctionKey func return; } ContainerScope scope(client->instanceId_); - TextInputAction action_ = static_cast(functionKey); + TextInputAction action_ = static_cast(functionKey.GetEnterKeyType()); switch (action_) { case TextInputAction::DONE: case TextInputAction::NEXT: diff --git a/frameworks/core/components/text_field/on_text_changed_listener_impl.h b/frameworks/core/components/text_field/on_text_changed_listener_impl.h index 8af6cc5ac68..ed76ab1c18a 100644 --- a/frameworks/core/components/text_field/on_text_changed_listener_impl.h +++ b/frameworks/core/components/text_field/on_text_changed_listener_impl.h @@ -33,7 +33,8 @@ public: void DeleteForward(int32_t length) override; void SetKeyboardStatus(bool status) override; void SendKeyEventFromInputMethod(const MiscServices::KeyEvent& event) override; - void SendKeyboardInfo(const MiscServices::KeyboardInfo& info) override; + void SendKeyboardStatus(const MiscServices::KeyboardStatus& keyboardStatus) override; + void SendFunctionKey(const MiscServices::FunctionKey& functionKey) override; void MoveCursor(MiscServices::Direction direction) override; void HandleSetSelection(int32_t start, int32_t end) override; void HandleExtendAction(int32_t action) override; diff --git a/frameworks/core/components_ng/pattern/text_field/on_text_changed_listener_impl.cpp b/frameworks/core/components_ng/pattern/text_field/on_text_changed_listener_impl.cpp index ba09e4ff25a..7ba3addefc6 100644 --- a/frameworks/core/components_ng/pattern/text_field/on_text_changed_listener_impl.cpp +++ b/frameworks/core/components_ng/pattern/text_field/on_text_changed_listener_impl.cpp @@ -81,13 +81,17 @@ void OnTextChangedListenerImpl::SetKeyboardStatus(bool status) void OnTextChangedListenerImpl::SendKeyEventFromInputMethod(const MiscServices::KeyEvent& event) {} -void OnTextChangedListenerImpl::SendKeyboardInfo(const MiscServices::KeyboardInfo& info) +void OnTextChangedListenerImpl::SendKeyboardStatus(const MiscServices::KeyboardStatus& keyboardStatus) { - LOGI("[OnTextChangedListenerImpl] KeyboardStatus status: %{public}d", info.GetKeyboardStatus()); + LOGI("[OnTextChangedListenerImpl] SendKeyboardStatus status: %{public}d", static_cast(keyboardStatus)); // this keyboard status means shown or hidden but attachment is not closed, should be distinguished from // imeAttached_ - HandleKeyboardStatus(info.GetKeyboardStatus()); - HandleFunctionKey(info.GetFunctionKey()); + HandleKeyboardStatus(keyboardStatus); +} + +void OnTextChangedListenerImpl::SendFunctionKey(const MiscServices::FunctionKey& functionKey) +{ + HandleFunctionKey(functionKey); } void OnTextChangedListenerImpl::HandleKeyboardStatus(MiscServices::KeyboardStatus status) @@ -101,12 +105,13 @@ void OnTextChangedListenerImpl::HandleKeyboardStatus(MiscServices::KeyboardStatu void OnTextChangedListenerImpl::HandleFunctionKey(MiscServices::FunctionKey functionKey) { - LOGI("[OnTextChangedListenerImpl] Handle function key %{public}d", static_cast(functionKey)); + LOGI("[OnTextChangedListenerImpl] Handle function key %{public}d", + static_cast(functionKey.GetEnterKeyType())); auto task = [textField = pattern_, functionKey] { auto client = textField.Upgrade(); CHECK_NULL_VOID(client); ContainerScope scope(client->GetInstanceId()); - TextInputAction action = static_cast(functionKey); + TextInputAction action = static_cast(functionKey.GetEnterKeyType()); switch (action) { case TextInputAction::DONE: case TextInputAction::NEXT: diff --git a/frameworks/core/components_ng/pattern/text_field/on_text_changed_listener_impl.h b/frameworks/core/components_ng/pattern/text_field/on_text_changed_listener_impl.h index 6038cf6302d..ae840a2aa90 100644 --- a/frameworks/core/components_ng/pattern/text_field/on_text_changed_listener_impl.h +++ b/frameworks/core/components_ng/pattern/text_field/on_text_changed_listener_impl.h @@ -32,7 +32,8 @@ public: void DeleteForward(int32_t length) override; void SetKeyboardStatus(bool status) override; void SendKeyEventFromInputMethod(const MiscServices::KeyEvent& event) override; - void SendKeyboardInfo(const MiscServices::KeyboardInfo& info) override; + void SendKeyboardStatus(const MiscServices::KeyboardStatus& keyboardStatus) override; + void SendFunctionKey(const MiscServices::FunctionKey& functionKey) override; void MoveCursor(MiscServices::Direction direction) override; void HandleSetSelection(int32_t start, int32_t end) override; void HandleExtendAction(int32_t action) override; -- Gitee