{\r
case Dali::Toolkit::Control::KeyboardFocus::LEFT:\r
{\r
- return (srcRect.right > destRect.right || srcRect.left >= destRect.right);\r
+ return (srcRect.right > destRect.right || srcRect.left >= destRect.right) && srcRect.left > destRect.left;\r
}\r
case Dali::Toolkit::Control::KeyboardFocus::RIGHT:\r
{\r
- return (srcRect.left < destRect.left || srcRect.right <= destRect.left);\r
+ return (srcRect.left < destRect.left || srcRect.right <= destRect.left) && srcRect.right < destRect.right;\r
}\r
case Dali::Toolkit::Control::KeyboardFocus::UP:\r
{\r
- return (srcRect.bottom > destRect.bottom || srcRect.top >= destRect.bottom);\r
+ return (srcRect.bottom > destRect.bottom || srcRect.top >= destRect.bottom) && srcRect.top > destRect.top;\r
}\r
case Dali::Toolkit::Control::KeyboardFocus::DOWN:\r
{\r
- return (srcRect.top < destRect.top || srcRect.bottom <= destRect.top);\r
+ return (srcRect.top < destRect.top || srcRect.bottom <= destRect.top) && srcRect.bottom < destRect.bottom;\r
}\r
default:\r
{\r
bool IsFocusable(Actor& actor)\r
{\r
return (actor.GetProperty<bool>(Actor::Property::KEYBOARD_FOCUSABLE) &&\r
+ actor.GetProperty<bool>(DevelActor::Property::USER_INTERACTION_ENABLED) &&\r
actor.GetProperty<bool>(Actor::Property::VISIBLE) &&\r
- actor.GetProperty<bool>(Actor::Property::SENSITIVE) &&\r
actor.GetProperty<Vector4>(Actor::Property::WORLD_COLOR).a > FULLY_TRANSPARENT);\r
}\r
\r
Actor FindNextFocus(Actor& actor, Actor& focusedActor, Rect<float>& focusedRect, Rect<float>& bestCandidateRect, Toolkit::Control::KeyboardFocus::Direction direction)\r
{\r
Actor nearestActor;\r
- if(actor)\r
+ if(actor && actor.GetProperty<bool>(Actor::Property::VISIBLE) && actor.GetProperty<bool>(DevelActor::Property::KEYBOARD_FOCUSABLE_CHILDREN))\r
{\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
\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(!rootActor)\r
{\r
return nearestActor;\r
}\r
\r
- Rect<float> focusedRect = DevelActor::CalculateScreenExtents(focusedActor);\r
+ Rect<float> focusedRect;\r
+ if (!focusedActor)\r
+ {\r
+ // If there is no currently focused actor, it is searched based on the upper left corner of the current window.\r
+ Rect<float> rootRect = DevelActor::CalculateScreenExtents(rootActor);\r
+ focusedRect = Rect<float>(rootRect.x, rootRect.y, 0.f, 0.f);\r
+ }\r
+ else\r
+ {\r
+ focusedRect = DevelActor::CalculateScreenExtents(focusedActor);\r
+ }\r
+\r
\r
// initialize the best candidate to something impossible\r
// (so the first plausible actor will become the best choice)\r
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