From 0e279a84726830fc0262af49e3599dff822475ae Mon Sep 17 00:00:00 2001 From: openharmony_ci <120357966@qq.com> Date: Fri, 22 Dec 2023 07:46:29 +0000 Subject: [PATCH] =?UTF-8?q?=E5=9B=9E=E9=80=80=20'Pull=20Request=20!22927?= =?UTF-8?q?=20:=20=20=E5=A2=9E=E5=8A=A0=E6=94=BE=E5=A4=A7=E9=95=9C?= =?UTF-8?q?=E5=85=B3=E9=97=AD=E8=A7=A6=E5=8F=91=E6=9D=A1=E4=BB=B6'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pattern/text_field/text_field_pattern.cpp | 24 +++++++------------ .../pattern/text_field/text_field_pattern.h | 1 - 2 files changed, 8 insertions(+), 17 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 295409ed583..5901e7bc882 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 @@ -402,10 +402,6 @@ bool TextFieldPattern::OnDirtyLayoutWrapperSwap(const RefPtr& dir inlineSelectAllFlag_ = false; showSelect_ = true; } - if (needSelectAll_ && !isLongPress_) { - HandleOnSelectAll(true); - needSelectAll_ = false; - } if (mouseStatus_ == MouseStatus::RELEASED) { mouseStatus_ = MouseStatus::NONE; } @@ -654,10 +650,6 @@ void TextFieldPattern::HandleFocusEvent() CHECK_NULL_VOID(paintProperty); auto layoutProperty = GetLayoutProperty(); CHECK_NULL_VOID(layoutProperty); - auto isSelectAll = layoutProperty->GetSelectAllValueValue(false); - if (isSelectAll && !contentController_->IsEmpty()) { - needSelectAll_ = true; - } if (IsNormalInlineState()) { ApplyInlineStates(true); inlineFocusState_ = true; @@ -1687,6 +1679,7 @@ void TextFieldPattern::HandleSingleClickEvent(GestureEvent& info) SetIsSingleHandle(true); CloseSelectOverlay(true); + auto isSelectAll = layoutProperty->GetSelectAllValueValue(false); if (RepeatClickCaret(info.GetLocalLocation(), lastCaretIndex) && info.GetSourceDevice() != SourceType::MOUSE) { if (contentController_->IsEmpty()) { ProcessOverlay(true, true, true, true); @@ -1697,7 +1690,8 @@ void TextFieldPattern::HandleSingleClickEvent(GestureEvent& info) && !IsNormalInlineState()) { if (GetNakedCharPosition() >= 0) { DelayProcessOverlay(true, true, false); - } else if (needSelectAll_) { + } else if (isSelectAll && !contentController_->IsEmpty() && isFocusedBeforeClick_) { + isFocusedBeforeClick_ = false; HandleOnSelectAll(true); } else { ProcessOverlay(true, true, false); @@ -1709,6 +1703,10 @@ void TextFieldPattern::HandleSingleClickEvent(GestureEvent& info) } // emulate clicking bottom of the textField UpdateTextFieldManager(Offset(parentGlobalOffset_.GetX(), parentGlobalOffset_.GetY()), frameRect_.Height()); + if (isSelectAll && !contentController_->IsEmpty() && isFocusedBeforeClick_) { + isFocusedBeforeClick_ = false; + HandleOnSelectAll(true); + } host->MarkDirtyNode(PROPERTY_UPDATE_RENDER); } @@ -1762,10 +1760,6 @@ bool TextFieldPattern::ProcessAutoFill() void TextFieldPattern::HandleDoubleClickEvent(GestureEvent& info) { - if (showSelect_) { - SetIsSingleHandle(true); - CloseSelectOverlay(); - } selectController_->UpdateSelectByOffset(info.GetLocalLocation()); if (IsSelected()) { StopTwinkling(); @@ -2224,6 +2218,7 @@ void TextFieldPattern::HandleLongPress(GestureEvent& info) ProcessOverlay(true, true); UpdateSelectMenuVisibility(true); } + isFocusedBeforeClick_ = false; host->MarkDirtyNode(PROPERTY_UPDATE_RENDER); } @@ -2569,9 +2564,6 @@ void TextFieldPattern::OnHandleClosed(bool closedByGlobalEvent) UpdateSelectMenuVisibility(false); } UpdateShowMagnifier(); - auto tmpHost = GetHost(); - CHECK_NULL_VOID(tmpHost); - tmpHost->MarkDirtyNode(PROPERTY_UPDATE_RENDER); } void TextFieldPattern::InitEditingValueText(std::string content) 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 978704f9005..1724bc0656d 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 @@ -1366,7 +1366,6 @@ private: bool isShowMagnifier_ = false; OffsetF localOffset_; bool isTouchCaret_ = false; - bool needSelectAll_ = false; }; } // namespace OHOS::Ace::NG -- Gitee