Merge "When using the auto-focusing function by enabling EnableDefaultAlgorithm,...
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / focus-manager / keyboard-focus-manager-impl.cpp
index 4afb39a..74e89dc 100644 (file)
@@ -516,13 +516,27 @@ bool KeyboardFocusManager::MoveFocus(Toolkit::Control::KeyboardFocus::Direction
         nextFocusableActor                  = mPreFocusChangeSignal.Emit(currentFocusActor, Actor(), direction);
         mIsWaitingKeyboardFocusChangeCommit = false;
       }
-      else if(mEnableDefaultAlgorithm && currentFocusActor)
+      else if (mEnableDefaultAlgorithm)
       {
-        // We should find it among the actors nearby.
-        Integration::SceneHolder window = Integration::SceneHolder::Get(currentFocusActor);
-        if(window)
+        Layer rootLayer;
+        if (currentFocusActor)
         {
-          nextFocusableActor = Toolkit::FocusFinder::GetNearestFocusableActor(window.GetRootLayer(), currentFocusActor, direction);
+          // Find the window of the focused actor.
+          Integration::SceneHolder window = Integration::SceneHolder::Get(currentFocusActor);
+          if (window)
+          {
+            rootLayer = window.GetRootLayer();
+          }
+        }
+        else
+        {
+          // Searches from the currently focused window.
+          rootLayer = mCurrentFocusedWindow.GetHandle();
+        }
+        if (rootLayer)
+        {
+          // We should find it among the actors nearby.
+          nextFocusableActor = Toolkit::FocusFinder::GetNearestFocusableActor(rootLayer, currentFocusActor, direction);
         }
       }
     }
@@ -784,20 +798,10 @@ void KeyboardFocusManager::OnKeyEvent(const KeyEvent& event)
   {
     if(keyName == "Left")
     {
-      if(!mIsFocusIndicatorShown)
+      if(mIsFocusIndicatorShown == HIDE)
       {
-        if(mIsFocusIndicatorShown == HIDE)
-        {
-          // Show focus indicator
-          mIsFocusIndicatorShown = SHOW;
-        }
-        else
-        {
-          // Move the focus towards left
-          MoveFocus(Toolkit::Control::KeyboardFocus::LEFT);
-        }
-
-        isFocusStartableKey = true;
+        // Show focus indicator
+        mIsFocusIndicatorShown = SHOW;
       }
       else
       {
@@ -809,18 +813,10 @@ void KeyboardFocusManager::OnKeyEvent(const KeyEvent& event)
     }
     else if(keyName == "Right")
     {
-      if(!mIsFocusIndicatorShown)
+      if(mIsFocusIndicatorShown == HIDE)
       {
-        if(mIsFocusIndicatorShown == HIDE)
-        {
-          // Show focus indicator
-          mIsFocusIndicatorShown = SHOW;
-        }
-        else
-        {
-          // Move the focus towards right
-          MoveFocus(Toolkit::Control::KeyboardFocus::RIGHT);
-        }
+        // Show focus indicator
+        mIsFocusIndicatorShown = SHOW;
       }
       else
       {