Changed GetNearestFocusableActor interface to receive rootActor
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / devel-api / focus-manager / focus-finder.cpp
index ddd0360..c52bf57 100644 (file)
@@ -354,9 +354,9 @@ Actor FindNextFocus(Actor& actor, Actor& focusedActor, Rect<float>& focusedRect,
   {\r
     // Recursively children\r
     const auto childCount = actor.GetChildCount();\r
-    for(auto i = 0u; i < childCount; ++i)\r
+    for(auto i = childCount; i > 0u; --i)\r
     {\r
-      Dali::Actor child = actor.GetChildAt(i);\r
+      Dali::Actor child = actor.GetChildAt(i-1);\r
       if(child && child != focusedActor && IsFocusable(child))\r
       {\r
         Rect<float> candidateRect = DevelActor::CalculateScreenExtents(child);\r
@@ -382,10 +382,10 @@ Actor FindNextFocus(Actor& actor, Actor& focusedActor, Rect<float>& focusedRect,
 \r
 } // unnamed namespace\r
 \r
-Actor GetNearestFocusableActor(Actor focusedActor, Toolkit::Control::KeyboardFocus::Direction direction)\r
+Actor GetNearestFocusableActor(Actor rootActor, Actor focusedActor, Toolkit::Control::KeyboardFocus::Direction direction)\r
 {\r
   Actor nearestActor;\r
-  if(!focusedActor)\r
+  if(!focusedActor || !rootActor)\r
   {\r
     return nearestActor;\r
   }\r
@@ -426,13 +426,7 @@ Actor GetNearestFocusableActor(Actor focusedActor, Toolkit::Control::KeyboardFoc
   ConvertCoordinate(bestCandidateRect);\r
 \r
   ConvertCoordinate(focusedRect);\r
-\r
-  Integration::SceneHolder window = Integration::SceneHolder::Get(focusedActor);\r
-  if(window)\r
-  {\r
-    Actor rootActor = window.GetRootLayer();\r
-    nearestActor    = FindNextFocus(rootActor, focusedActor, focusedRect, bestCandidateRect, direction);\r
-  }\r
+  nearestActor = FindNextFocus(rootActor, focusedActor, focusedRect, bestCandidateRect, direction);\r
   return nearestActor;\r
 }\r
 \r