+ Actor nextFocusableActor;
+
+ Toolkit::Control currentFocusControl = Toolkit::Control::DownCast(currentFocusActor);
+
+ // If the current focused actor is a control, then find the next focusable actor via the focusable properties.
+ if(currentFocusControl)
+ {
+ int actorId = -1;
+ Property::Index index = Property::INVALID_INDEX;
+ Property::Value value;
+
+ // Find property index based upon focus direction
+ switch(direction)
+ {
+ case Toolkit::Control::KeyboardFocus::LEFT:
+ {
+ index = Toolkit::DevelControl::Property::LEFT_FOCUSABLE_ACTOR_ID;
+ break;
+ }
+ case Toolkit::Control::KeyboardFocus::RIGHT:
+ {
+ index = Toolkit::DevelControl::Property::RIGHT_FOCUSABLE_ACTOR_ID;
+ break;
+ }
+ case Toolkit::Control::KeyboardFocus::UP:
+ {
+ index = Toolkit::DevelControl::Property::UP_FOCUSABLE_ACTOR_ID;
+ break;
+ }
+ case Toolkit::Control::KeyboardFocus::DOWN:
+ {
+ index = Toolkit::DevelControl::Property::DOWN_FOCUSABLE_ACTOR_ID;
+ break;
+ }
+ case Toolkit::Control::KeyboardFocus::CLOCKWISE:
+ {
+ index = Toolkit::DevelControl::Property::CLOCKWISE_FOCUSABLE_ACTOR_ID;
+ break;
+ }
+ case Toolkit::Control::KeyboardFocus::COUNTER_CLOCKWISE:
+ {
+ index = Toolkit::DevelControl::Property::COUNTER_CLOCKWISE_FOCUSABLE_ACTOR_ID;
+ break;
+ }
+ default:
+ break;
+ }
+
+ // If the focusable property is set then determine next focusable actor
+ if(index != Property::INVALID_INDEX)
+ {
+ value = currentFocusActor.GetProperty(index);
+ actorId = value.Get<int>();
+
+ // If actor's id is valid then find actor form actor's id. The actor should be on the stage.
+ if(actorId != -1)
+ {
+ if(currentFocusActor.GetParent())
+ {
+ nextFocusableActor = currentFocusActor.GetParent().FindChildById(actorId);
+ }
+
+ if(!nextFocusableActor)
+ {
+ Integration::SceneHolder window = Integration::SceneHolder::Get(currentFocusActor);
+ if(window)
+ {
+ nextFocusableActor = window.GetRootLayer().FindChildById(actorId);
+ }
+ }
+ }
+ }
+ }
+
+ if(!nextFocusableActor)
+ {
+ // If the implementation of CustomAlgorithmInterface is provided then the PreFocusChangeSignal is no longer emitted.
+ if(mCustomAlgorithmInterface)
+ {
+ mIsWaitingKeyboardFocusChangeCommit = true;
+ nextFocusableActor = mCustomAlgorithmInterface->GetNextFocusableActor(currentFocusActor, Actor(), direction, deviceName);
+ mIsWaitingKeyboardFocusChangeCommit = false;
+ }
+ else if(!mPreFocusChangeSignal.Empty())
+ {
+ // Don't know how to move the focus further. The application needs to tell us which actor to move the focus to
+ mIsWaitingKeyboardFocusChangeCommit = true;
+ nextFocusableActor = mPreFocusChangeSignal.Emit(currentFocusActor, Actor(), direction);
+ mIsWaitingKeyboardFocusChangeCommit = false;
+ }
+ else if(mEnableDefaultAlgorithm)
+ {
+ Actor rootActor = mFocusFinderRootActor.GetHandle();
+ if(!rootActor)
+ {
+ if(currentFocusActor)
+ {
+ // Find the window of the focused actor.
+ Integration::SceneHolder window = Integration::SceneHolder::Get(currentFocusActor);
+ if(window)
+ {
+ rootActor = window.GetRootLayer();
+ }
+ }
+ else
+ {
+ // Searches from the currently focused window.
+ rootActor = mCurrentFocusedWindow.GetHandle();
+ }
+ }
+ if(rootActor)
+ {
+ // We should find it among the actors nearby.
+ nextFocusableActor = Toolkit::FocusFinder::GetNearestFocusableActor(rootActor, currentFocusActor, direction);
+ }
+ }
+ }