Revert "Fix focus issue after calling ClearFocus api"
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / focus-manager / keyboard-focus-manager-impl.cpp
index 9e34984..3555b3c 100644 (file)
@@ -123,6 +123,7 @@ KeyboardFocusManager::KeyboardFocusManager()
   mFocusGroupLoopEnabled( false ),
   mIsWaitingKeyboardFocusChangeCommit( false ),
   mClearFocusOnTouch( true ),
+  mEnableFocusIndicator( true ),
   mFocusHistory(),
   mSlotDelegate( this ),
   mCustomAlgorithmInterface(NULL)
@@ -178,7 +179,7 @@ bool KeyboardFocusManager::DoSetCurrentFocusActor( Actor actor )
   // Check whether the actor is in the stage and is keyboard focusable.
   if( actor && actor.IsKeyboardFocusable() && actor.OnStage() )
   {
-    if( mIsFocusIndicatorEnabled )
+    if( mIsFocusIndicatorEnabled && mEnableFocusIndicator )
     {
       actor.Add( GetFocusIndicatorActor() );
     }
@@ -672,9 +673,12 @@ void KeyboardFocusManager::OnKeyEvent(const KeyEvent& event)
           // Show focus indicator
           mIsFocusIndicatorEnabled = 1;
         }
+        else
+        {
+          // Move the focus towards left
+          MoveFocus(Toolkit::Control::KeyboardFocus::LEFT);
+        }
 
-        // Move the focus towards left
-        MoveFocus(Toolkit::Control::KeyboardFocus::LEFT);
         isFocusStartableKey = true;
       }
       else
@@ -692,9 +696,11 @@ void KeyboardFocusManager::OnKeyEvent(const KeyEvent& event)
           // Show focus indicator
           mIsFocusIndicatorEnabled = 1;
         }
-
-        // Move the focus towards right
-        MoveFocus(Toolkit::Control::KeyboardFocus::RIGHT);
+        else
+        {
+          // Move the focus towards right
+          MoveFocus(Toolkit::Control::KeyboardFocus::RIGHT);
+        }
       }
       else
       {
@@ -711,9 +717,12 @@ void KeyboardFocusManager::OnKeyEvent(const KeyEvent& event)
         // Show focus indicator
         mIsFocusIndicatorEnabled = 1;
       }
+      else
+      {
+        // Move the focus towards up
+        MoveFocus(Toolkit::Control::KeyboardFocus::UP);
+      }
 
-      // Move the focus towards up
-      MoveFocus(Toolkit::Control::KeyboardFocus::UP);
       isFocusStartableKey = true;
     }
     else if (keyName == "Down" && !isAccessibilityEnabled)
@@ -723,9 +732,12 @@ void KeyboardFocusManager::OnKeyEvent(const KeyEvent& event)
         // Show focus indicator
         mIsFocusIndicatorEnabled = 1;
       }
+      else
+      {
+        // Move the focus towards down
+        MoveFocus(Toolkit::Control::KeyboardFocus::DOWN);
+      }
 
-      // Move the focus towards down
-      MoveFocus(Toolkit::Control::KeyboardFocus::DOWN);
       isFocusStartableKey = true;
     }
     else if (keyName == "Prior" && !isAccessibilityEnabled)
@@ -735,9 +747,11 @@ void KeyboardFocusManager::OnKeyEvent(const KeyEvent& event)
         // Show focus indicator
         mIsFocusIndicatorEnabled = 1;
       }
-
-      // Move the focus towards the previous page
-      MoveFocus(Toolkit::Control::KeyboardFocus::PAGE_UP);
+      else
+      {
+        // Move the focus towards the previous page
+        MoveFocus(Toolkit::Control::KeyboardFocus::PAGE_UP);
+      }
 
       isFocusStartableKey = true;
     }
@@ -748,9 +762,11 @@ void KeyboardFocusManager::OnKeyEvent(const KeyEvent& event)
         // Show focus indicator
         mIsFocusIndicatorEnabled = 1;
       }
-
-      // Move the focus towards the next page
-      MoveFocus(Toolkit::Control::KeyboardFocus::PAGE_DOWN);
+      else
+      {
+        // Move the focus towards the next page
+        MoveFocus(Toolkit::Control::KeyboardFocus::PAGE_DOWN);
+      }
 
       isFocusStartableKey = true;
     }
@@ -836,8 +852,11 @@ void KeyboardFocusManager::OnKeyEvent(const KeyEvent& event)
     Actor actor = GetCurrentFocusActor();
     if( actor )
     {
-      // Make sure the focused actor is highlighted
-      actor.Add( GetFocusIndicatorActor() );
+      if( mEnableFocusIndicator )
+      {
+        // Make sure the focused actor is highlighted
+        actor.Add( GetFocusIndicatorActor() );
+      }
     }
     else
     {
@@ -923,6 +942,21 @@ void KeyboardFocusManager::SetCustomAlgorithm(CustomAlgorithmInterface& interfac
   mCustomAlgorithmInterface = &interface;
 }
 
+void KeyboardFocusManager::EnableFocusIndicator(bool enable)
+{
+  if( !enable && mFocusIndicatorActor )
+  {
+    mFocusIndicatorActor.Unparent();
+  }
+
+  mEnableFocusIndicator = enable;
+}
+
+bool KeyboardFocusManager::IsFocusIndicatorEnabled() const
+{
+  return mEnableFocusIndicator;
+}
+
 } // namespace Internal
 
 } // namespace Toolkit