Changed to not always clearFocus when a touch occurs. 53/272953/8
authorjoogab.yun <joogab.yun@samsung.com>
Mon, 28 Mar 2022 10:13:28 +0000 (19:13 +0900)
committerjoogab.yun <joogab.yun@samsung.com>
Wed, 30 Mar 2022 07:12:08 +0000 (16:12 +0900)
Do ClearFocus when focus movement is possible.

Otherwise, only the FocusIndicator is cleared.

Change-Id: I7e482e78e0af590304d066549a554d4fa39d3613

automated-tests/src/dali-toolkit/utc-Dali-KeyboardFocusManager.cpp
dali-toolkit/internal/focus-manager/keyboard-focus-manager-impl.cpp
dali-toolkit/internal/focus-manager/keyboard-focus-manager-impl.h

index 7b08e1a..f32a64f 100644 (file)
@@ -1936,8 +1936,8 @@ int UtcDaliKeyboardFocusManagerSetAndGetCurrentFocusActorInTouchMode(void)
   application.SendNotification();
   application.Render();
 
-  // Check that the focus is successfully to clear
-  DALI_TEST_CHECK(manager.GetCurrentFocusActor() == Actor());
+  // Since no focus has been moved, the current focus actor is the same.
+  DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first);
 
   // Make the second actor focusableInTouchMode
   second.SetProperty(DevelActor::Property::TOUCH_FOCUSABLE, true);
index d492a29..bdfdded 100644 (file)
@@ -679,14 +679,10 @@ void KeyboardFocusManager::DoKeyboardEnter(Actor actor)
 
 void KeyboardFocusManager::ClearFocus()
 {
+  ClearFocusIndicator();
   Actor actor = GetCurrentFocusActor();
   if(actor)
   {
-    if(mFocusIndicatorActor)
-    {
-      actor.Remove(mFocusIndicatorActor);
-    }
-
     // Send notification for the change of focus actor
     if(!mFocusChangedSignal.Empty())
     {
@@ -700,8 +696,19 @@ void KeyboardFocusManager::ClearFocus()
       currentlyFocusedControl.ClearKeyInputFocus();
     }
   }
-
   mCurrentFocusActor.Reset();
+}
+
+void KeyboardFocusManager::ClearFocusIndicator()
+{
+  Actor actor = GetCurrentFocusActor();
+  if(actor)
+  {
+    if(mFocusIndicatorActor)
+    {
+      actor.Remove(mFocusIndicatorActor);
+    }
+  }
   mIsFocusIndicatorShown = (mAlwaysShowIndicator == ALWAYS_SHOW) ? SHOW : HIDE;
 }
 
@@ -1003,18 +1010,30 @@ void KeyboardFocusManager::OnTouch(const TouchEvent& touch)
   // We only do this on a Down event, otherwise the clear action may override a manually focused actor.
   if(((touch.GetPointCount() < 1) || (touch.GetState(0) == PointState::DOWN)))
   {
-    // If mClearFocusOnTouch is false, do not clear the focus even if user touch the screen.
-    if(mClearFocusOnTouch)
+    // If you touch the currently focused actor again, you don't need to do SetCurrentFocusActor again.
+    Actor hitActor = touch.GetHitActor(0);
+    if(hitActor && hitActor == GetCurrentFocusActor())
     {
-      ClearFocus();
+      return;
     }
-
     // If KEYBOARD_FOCUSABLE and TOUCH_FOCUSABLE is true, set focus actor
-    Actor hitActor = touch.GetHitActor(0);
     if(hitActor && hitActor.GetProperty<bool>(Actor::Property::KEYBOARD_FOCUSABLE) && hitActor.GetProperty<bool>(DevelActor::Property::TOUCH_FOCUSABLE))
     {
+      // If mClearFocusOnTouch is false, do not clear the focus
+      if(mClearFocusOnTouch)
+      {
+        ClearFocus();
+      }
       SetCurrentFocusActor(hitActor);
     }
+    else
+    {
+      // If mClearFocusOnTouch is false, do not clear the focus indicator even if user touch the screen.
+      if(mClearFocusOnTouch)
+      {
+        ClearFocusIndicator();
+      }
+    }
   }
 }
 
index 3b09623..ae06097 100644 (file)
@@ -323,6 +323,11 @@ private:
    */
   bool EmitCustomWheelSignals(Actor actor, const WheelEvent& event);
 
+  /**
+   * Clear the focus indicator actor.
+   */
+  void ClearFocusIndicator();
+
 private:
   // Undefined
   KeyboardFocusManager(const KeyboardFocusManager&);