From c178ce9613acea17bdb4bca0c8f694150c102bb5 Mon Sep 17 00:00:00 2001 From: zhouyan Date: Tue, 2 Jan 2024 03:40:56 +0000 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DtouchUp=E4=BA=8B=E4=BB=B6?= =?UTF-8?q?=E4=B8=A2=E5=A4=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhouyan Change-Id: Idab53d63a83a9a1baf8aef8073b634b0b627ea1b --- .../pattern/text_field/text_field_pattern.cpp | 26 +++++++++++-------- .../pattern/text_field/text_field_pattern.h | 1 + 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/frameworks/core/components_ng/pattern/text_field/text_field_pattern.cpp b/frameworks/core/components_ng/pattern/text_field/text_field_pattern.cpp index 69c967b8cd4..eda37939843 100644 --- a/frameworks/core/components_ng/pattern/text_field/text_field_pattern.cpp +++ b/frameworks/core/components_ng/pattern/text_field/text_field_pattern.cpp @@ -1289,10 +1289,14 @@ void TextFieldPattern::FireEventHubOnChange(const std::string& text) void TextFieldPattern::HandleTouchEvent(const TouchEventInfo& info) { + auto touchType = info.GetTouches().front().GetTouchType(); + if (touchType == TouchType::UP) { + RequestKeyboardAfterLongPress(); + } if (SelectOverlayIsOn() && !isTouchCaret_) { return; } - auto touchType = info.GetTouches().front().GetTouchType(); + if (touchType == TouchType::DOWN) { HandleTouchDown(info.GetTouches().front().GetLocalLocation()); } else if (touchType == TouchType::UP) { @@ -1356,14 +1360,6 @@ void TextFieldPattern::HandleTouchUp() } } } -#if defined(OHOS_STANDARD_SYSTEM) && !defined(PREVIEW) - if (isLongPress_ && !imeShown_ && !isCustomKeyboardAttached_ && HasFocus()) { - if (RequestKeyboard(false, true, true)) { - NotifyOnEditChanged(true); - } - } - isLongPress_ = false; -#endif } void TextFieldPattern::HandleTouchMove(const TouchEventInfo& info) @@ -2385,8 +2381,6 @@ bool TextFieldPattern::OnPreShowSelectOverlay( isSupportCameraInput_ = false; #endif overlayInfo.menuInfo.showCameraInput = !IsSelected() && isSupportCameraInput_ && !customKeyboardBuilder_; - auto gesture = host->GetOrCreateGestureEventHub(); - gesture->RemoveTouchEvent(GetTouchListener()); return true; } @@ -6232,4 +6226,14 @@ void TextFieldPattern::HandleOnDragStatusCallback( break; } } + +void TextFieldPattern::RequestKeyboardAfterLongPress() +{ +#if defined(OHOS_STANDARD_SYSTEM) && !defined(PREVIEW) + if (isLongPress_ && HasFocus() && RequestKeyboard(false, true, true)) { + NotifyOnEditChanged(true); + } + isLongPress_ = false; +#endif +} } // namespace OHOS::Ace::NG diff --git a/frameworks/core/components_ng/pattern/text_field/text_field_pattern.h b/frameworks/core/components_ng/pattern/text_field/text_field_pattern.h index 72e7ef59e86..476fdb82e46 100644 --- a/frameworks/core/components_ng/pattern/text_field/text_field_pattern.h +++ b/frameworks/core/components_ng/pattern/text_field/text_field_pattern.h @@ -1229,6 +1229,7 @@ private: void ScrollToSafeArea() const override; void RecordSubmitEvent() const; void UpdateCancelNode(); + void RequestKeyboardAfterLongPress(); RectF frameRect_; RectF contentRect_; -- Gitee