Fixed KeyboardFocusManager::ClearFocus is called twice on focus loss
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / focus-manager / keyboard-focus-manager-impl.cpp
index 4e57496..ae7d741 100644 (file)
@@ -132,9 +132,9 @@ bool KeyboardFocusManager::SetCurrentFocusActor(Actor actor)
 {
   DALI_ASSERT_DEBUG( !mIsWaitingKeyboardFocusChangeCommit && "Calling this function in the PreFocusChangeSignal callback?" );
 
-  if(actor)
+  if( actor )
   {
-    return DoSetCurrentFocusActor(actor.GetId());
+    return DoSetCurrentFocusActor( actor.GetId() );
   }
 
   return false;
@@ -695,8 +695,12 @@ void KeyboardFocusManager::OnKeyEvent(const KeyEvent& event)
 
 void KeyboardFocusManager::OnTouched(const TouchEvent& touchEvent)
 {
-  // Clear the focus when user touch the screen
-  ClearFocus();
+  // Clear the focus when user touch the screen.
+  // We only do this on a Down event, otherwise the clear action may override a manually focused actor.
+  if( ( touchEvent.GetPointCount() < 1 ) || ( touchEvent.GetPoint( 0 ).state == TouchPoint::Down ) )
+  {
+    ClearFocus();
+  }
 }
 
 Toolkit::KeyboardFocusManager::PreFocusChangeSignalType& KeyboardFocusManager::PreFocusChangeSignal()