// button1 -- button2
button1.SetProperty(Actor::Property::POSITION, Vector2(0.0f, 0.0f));
button2.SetProperty(Actor::Property::POSITION, Vector2(100.0f, 0.0f));
+ button1.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
+ button2.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
// flush the queue and render once
application.SendNotification();
// Move the focus towards left, The focus move will success because the default algorithm is enabled.
// [button1] -- button2
DALI_TEST_CHECK(manager.MoveFocus(Control::KeyboardFocus::LEFT) == true);
- // Confirm whether focus is moved to button2
+ // Confirm whether focus is moved to button1
DALI_TEST_EQUALS(button1.GetProperty<int>(DevelControl::Property::STATE), (int)DevelControl::FOCUSED, TEST_LOCATION);
DALI_TEST_CHECK(focusChangedCallback.mSignalVerified);
DALI_TEST_CHECK(focusChangedCallback.mOriginalFocusedActor == button2);
DALI_TEST_CHECK(focusChangedCallback.mCurrentFocusedActor == button1);
focusChangedCallback.Reset();
+ // Clears focus.
+ manager.ClearFocus();
+ // There is no actor focused.
+ // button1 -- button2
+ DALI_TEST_CHECK(manager.GetCurrentFocusActor() == Actor());
+
+ // Move the focus towards right, The focus is on the actor closest to the top left of the window.
+ // [button1] -- button2
+ DALI_TEST_CHECK(manager.MoveFocus(Control::KeyboardFocus::RIGHT) == true);
+
+ // Confirm whether focus is moved to button1
+ DALI_TEST_EQUALS(button1.GetProperty<int>(DevelControl::Property::STATE), (int)DevelControl::FOCUSED, TEST_LOCATION);
+ DALI_TEST_CHECK(focusChangedCallback.mSignalVerified);
+ DALI_TEST_CHECK(focusChangedCallback.mOriginalFocusedActor == Actor());
+ DALI_TEST_CHECK(focusChangedCallback.mCurrentFocusedActor == button1);
+ focusChangedCallback.Reset();
+
+
END_TEST;
}
Actor GetNearestFocusableActor(Actor rootActor, Actor focusedActor, Toolkit::Control::KeyboardFocus::Direction direction)\r
{\r
Actor nearestActor;\r
- if(!focusedActor || !rootActor)\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
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);
}
}
}