diff --git a/ui/touch_selection/longpress_drag_selector.h b/ui/touch_selection/longpress_drag_selector.h index eac82080555cdcaebcd492637258c4561417ffde..2dfed476902bb36394ce9e215242aa2536c0dcff 100644 --- a/ui/touch_selection/longpress_drag_selector.h +++ b/ui/touch_selection/longpress_drag_selector.h @@ -37,6 +37,10 @@ class UI_TOUCH_SELECTION_EXPORT LongPressDragSelector bool WillHandleTouchEvent(const MotionEvent& event) override; bool IsActive() const override; +#ifdef OHOS_CLIPBOARD + bool IsDragging() const override { return state_ == DRAGGING; } +#endif + // Called just prior to a longpress event being handled. void OnLongPressEvent(base::TimeTicks event_time, const gfx::PointF& position); diff --git a/ui/touch_selection/touch_selection_controller.cc b/ui/touch_selection/touch_selection_controller.cc index 0b6ba9a588b2ecffd56c9b13fca0d63f4ea212bb..f6c448edeb03b0b7bb8d26273c2396c4e120621a 100644 --- a/ui/touch_selection/touch_selection_controller.cc +++ b/ui/touch_selection/touch_selection_controller.cc @@ -11,6 +11,7 @@ #include "base/metrics/histogram_macros.h" #include "base/metrics/user_metrics.h" #include "base/notreached.h" +#include "base/logging.h" namespace ui { namespace { @@ -69,16 +70,40 @@ TouchSelectionController::~TouchSelectionController() { void TouchSelectionController::OnSelectionBoundsChanged( const gfx::SelectionBound& start, const gfx::SelectionBound& end) { - if (start == start_ && end_ == end) + if (start == start_ && end_ == end) { +#ifdef OHOS_CLIPBOARD + reset_selection_temporarily_ = false; +#endif return; + } if (start.type() == gfx::SelectionBound::EMPTY || end.type() == gfx::SelectionBound::EMPTY || !show_touch_handles_) { +#ifdef OHOS_CLIPBOARD + if (active_status_ == SELECTION_ACTIVE && start_selection_handle_ && + end_selection_handle_ && show_touch_handles_) { + if (start_selection_handle_->IsActive() || + end_selection_handle_->IsActive()) { + LOG(INFO) << "selection temporarily hide"; + reset_selection_temporarily_ = true; + return; + } + } + if (longpress_drag_selector_.IsDragging()) { + LOG(INFO) << "long selection temporarily hide"; + reset_selection_temporarily_ = true; + return; + } +#endif HideHandles(); return; } +#ifdef OHOS_CLIPBOARD + reset_selection_temporarily_ = false; +#endif + // Swap the Handles when the start and end selection points cross each other. if (active_status_ == SELECTION_ACTIVE) { // Bounds have the same orientation. @@ -461,7 +486,8 @@ void TouchSelectionController::OnDragBegin( selection_handle_dragged_ = true; #ifdef OHOS_CLIPBOARD - selection_handle_orientation_dragging_ = anchor_drag_to_selection_start_ + reset_selection_temporarily_ = false; + selection_handle_orientation_dragging_ = anchor_drag_to_selection_start_ ? TouchHandleOrientation::LEFT : TouchHandleOrientation::RIGHT; #endif @@ -515,7 +541,11 @@ void TouchSelectionController::OnDragUpdate( void TouchSelectionController::OnDragEnd( const TouchSelectionDraggable& draggable) { #ifdef OHOS_CLIPBOARD - selection_handle_orientation_dragging_ = TouchHandleOrientation::UNDEFINED; + if(reset_selection_temporarily_){ + LOG(INFO)<<"reset_selection_temporarily_ HideHandles"; + HideHandles(); + } + selection_handle_orientation_dragging_ = TouchHandleOrientation::UNDEFINED; #endif if (&draggable == insertion_handle_.get()) client_->OnSelectionEvent(INSERTION_HANDLE_DRAG_STOPPED); diff --git a/ui/touch_selection/touch_selection_controller.h b/ui/touch_selection/touch_selection_controller.h index c080ccbd72e179c1636aa95c71469bbf296a8d1c..b1509c19a29c312376ccfee61db8d9715ce806d5 100644 --- a/ui/touch_selection/touch_selection_controller.h +++ b/ui/touch_selection/touch_selection_controller.h @@ -279,6 +279,8 @@ class UI_TOUCH_SELECTION_EXPORT TouchSelectionController #ifdef OHOS_CLIPBOARD bool is_long_press_ = false; + + bool reset_selection_temporarily_ = false; #endif }; diff --git a/ui/touch_selection/touch_selection_draggable.h b/ui/touch_selection/touch_selection_draggable.h index 2f5b15c80e023345bef97e3072a724b4c0b9117e..8aff07877b638551a1727b3aff51273be781dcdc 100644 --- a/ui/touch_selection/touch_selection_draggable.h +++ b/ui/touch_selection/touch_selection_draggable.h @@ -48,6 +48,10 @@ class UI_TOUCH_SELECTION_EXPORT TouchSelectionDraggable { // Whether a drag is active OR being detected for the current touch sequence. virtual bool IsActive() const = 0; + +#ifdef OHOS_CLIPBOARD + virtual bool IsDragging() const { return false; } +#endif }; } // namespace ui