Move the point of setting currentFocusControl to before FocusLost. 77/289777/7
authorjoogab.yun <joogab.yun@samsung.com>
Tue, 14 Mar 2023 08:01:39 +0000 (17:01 +0900)
committerjoogab.yun <joogab.yun@samsung.com>
Mon, 24 Apr 2023 03:36:42 +0000 (12:36 +0900)
The FocusLost event has happened, but HasKeyInputFocus() still returns true.
Therefore, move the currentFocusControl setting point to before the FocusLost event.

Change-Id: Ib8152dec1beb1959aef61dbc73f5ce522e6db72e

automated-tests/src/dali-toolkit/dali-toolkit-test-utils/dummy-control.cpp
dali-toolkit/internal/focus-manager/keyinput-focus-manager-impl.cpp

index 7d0c661..56b3b5e 100644 (file)
@@ -268,8 +268,20 @@ void Impl::DummyControl::OnChildRemove(Actor& child) { childRemoveCalled = true;
 void Impl::DummyControl::OnSizeSet(const Vector3& targetSize) { Control::OnSizeSet( targetSize ); sizeSetCalled = true; }
 void Impl::DummyControl::OnSizeAnimation(Animation& animation, const Vector3& targetSize) { Control::OnSizeAnimation( animation, targetSize ); sizeAnimationCalled = true; }
 bool Impl::DummyControl::OnKeyEvent(const KeyEvent& event) { keyEventCalled = true; return false;}
-void Impl::DummyControl::OnKeyInputFocusGained() { keyInputFocusGained = true; }
-void Impl::DummyControl::OnKeyInputFocusLost() { keyInputFocusLost = true; }
+void Impl::DummyControl::OnKeyInputFocusGained()
+{
+  if(this->HasKeyInputFocus())
+  {
+    keyInputFocusGained = true;
+  }
+}
+void Impl::DummyControl::OnKeyInputFocusLost()
+{
+  if(!this->HasKeyInputFocus())
+  {
+    keyInputFocusLost = true;
+  }
+}
 
 void Impl::DummyControl::SetLayout( Property::Index visualIndex, Property::Map& map )
 {
index ebdb214..88da9b7 100644 (file)
@@ -84,15 +84,16 @@ void KeyInputFocusManager::SetFocus(Toolkit::Control control)
   control.OffSceneSignal().Connect(mSlotDelegate, &KeyInputFocusManager::OnFocusControlSceneDisconnection);
 
   Dali::Toolkit::Control previousFocusControl = GetCurrentFocusControl();
+
+  // Set control to currentFocusControl
+  mCurrentFocusControl = control;
+
   if(previousFocusControl)
   {
     // Notify the control that it has lost key input focus
     GetImplementation(previousFocusControl).OnKeyInputFocusLost();
   }
 
-  // Set control to currentFocusControl
-  mCurrentFocusControl = control;
-
   // Tell the new actor that it has gained focus.
   GetImplementation(control).OnKeyInputFocusGained();
 
@@ -109,10 +110,10 @@ void KeyInputFocusManager::RemoveFocus(Toolkit::Control control)
   {
     control.OffSceneSignal().Disconnect(mSlotDelegate, &KeyInputFocusManager::OnFocusControlSceneDisconnection);
 
+    mCurrentFocusControl.Reset();
+
     // Notify the control that it has lost key input focus
     GetImplementation(control).OnKeyInputFocusLost();
-
-    mCurrentFocusControl.Reset();
   }
 }