2 * Copyright (c) 2017 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include "keyboard-focus-manager-impl.h"
22 #include <cstring> // for strcmp
23 #include <dali/public-api/actors/layer.h>
24 #include <dali/devel-api/adaptor-framework/accessibility-adaptor.h>
25 #include <dali/devel-api/adaptor-framework/singleton-service.h>
26 #include <dali/public-api/animation/constraints.h>
27 #include <dali/public-api/common/stage.h>
28 #include <dali/public-api/events/key-event.h>
29 #include <dali/public-api/events/touch-data.h>
30 #include <dali/public-api/object/type-registry.h>
31 #include <dali/public-api/object/type-registry-helper.h>
32 #include <dali/public-api/images/resource-image.h>
33 #include <dali/integration-api/debug.h>
36 #include <dali-toolkit/public-api/controls/control.h>
37 #include <dali-toolkit/public-api/controls/control-impl.h>
38 #include <dali-toolkit/public-api/controls/image-view/image-view.h>
39 #include <dali-toolkit/public-api/accessibility-manager/accessibility-manager.h>
40 #include <dali-toolkit/devel-api/controls/control-devel.h>
51 namespace // Unnamed namespace
54 #if defined(DEBUG_ENABLED)
55 Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_KEYBOARD_FOCUS_MANAGER");
58 const char* const IS_FOCUS_GROUP_PROPERTY_NAME = "isKeyboardFocusGroup"; // This property will be replaced by a flag in Control.
60 const char* const FOCUS_BORDER_IMAGE_PATH = DALI_IMAGE_DIR "keyboard_focus.9.png";
64 BaseHandle handle = KeyboardFocusManager::Get();
68 SingletonService singletonService( SingletonService::Get() );
69 if ( singletonService )
71 Toolkit::KeyboardFocusManager manager = Toolkit::KeyboardFocusManager( new Internal::KeyboardFocusManager() );
72 singletonService.Register( typeid( manager ), manager );
80 DALI_TYPE_REGISTRATION_BEGIN_CREATE( Toolkit::KeyboardFocusManager, Dali::BaseHandle, Create, true )
82 DALI_SIGNAL_REGISTRATION( Toolkit, KeyboardFocusManager, "keyboardPreFocusChange", SIGNAL_PRE_FOCUS_CHANGE )
83 DALI_SIGNAL_REGISTRATION( Toolkit, KeyboardFocusManager, "keyboardFocusChanged", SIGNAL_FOCUS_CHANGED )
84 DALI_SIGNAL_REGISTRATION( Toolkit, KeyboardFocusManager, "keyboardFocusGroupChanged", SIGNAL_FOCUS_GROUP_CHANGED )
85 DALI_SIGNAL_REGISTRATION( Toolkit, KeyboardFocusManager, "keyboardFocusedActorEnterKey", SIGNAL_FOCUSED_ACTOR_ENTER_KEY )
87 DALI_TYPE_REGISTRATION_END()
89 const unsigned int MAX_HISTORY_AMOUNT = 30; ///< Max length of focus history stack
91 } // unnamed namespace
93 Toolkit::KeyboardFocusManager KeyboardFocusManager::Get()
95 Toolkit::KeyboardFocusManager manager;
97 SingletonService singletonService( SingletonService::Get() );
98 if ( singletonService )
100 // Check whether the keyboard focus manager is already created
101 Dali::BaseHandle handle = singletonService.GetSingleton( typeid( Toolkit::KeyboardFocusManager ) );
104 // If so, downcast the handle of singleton to keyboard focus manager
105 manager = Toolkit::KeyboardFocusManager( dynamic_cast< KeyboardFocusManager* >( handle.GetObjectPtr() ) );
112 KeyboardFocusManager::KeyboardFocusManager()
113 : mPreFocusChangeSignal(),
114 mFocusChangedSignal(),
115 mFocusGroupChangedSignal(),
116 mFocusedActorEnterKeySignal(),
117 mCurrentFocusActor( 0 ),
118 mFocusIndicatorActor(),
119 mFocusGroupLoopEnabled( false ),
120 mIsFocusIndicatorEnabled( true ),
121 mIsWaitingKeyboardFocusChangeCommit( false ),
123 mSlotDelegate( this ),
124 mCustomAlgorithmInterface(NULL)
126 // TODO: Get FocusIndicatorEnable constant from stylesheet to set mIsFocusIndicatorEnabled.
127 Stage::GetCurrent().KeyEventSignal().Connect( mSlotDelegate, &KeyboardFocusManager::OnKeyEvent);
128 Stage::GetCurrent().TouchSignal().Connect( mSlotDelegate, &KeyboardFocusManager::OnTouch );
131 KeyboardFocusManager::~KeyboardFocusManager()
135 bool KeyboardFocusManager::SetCurrentFocusActor( Actor actor )
137 DALI_ASSERT_DEBUG( !mIsWaitingKeyboardFocusChangeCommit && "Calling this function in the PreFocusChangeSignal callback?" );
139 return DoSetCurrentFocusActor( actor );
142 bool KeyboardFocusManager::DoSetCurrentFocusActor( Actor actor )
144 bool success = false;
146 Actor currentFocusedActor = GetCurrentFocusActor();
148 // If developer set focus on same actor, doing nothing
149 if( actor == currentFocusedActor )
158 // Check whether the actor is in the stage and is keyboard focusable.
159 if( actor && actor.IsKeyboardFocusable() )
161 if( mIsFocusIndicatorEnabled )
163 actor.Add( GetFocusIndicatorActor() );
166 // Send notification for the change of focus actor
167 if( !mFocusChangedSignal.Empty() )
169 mFocusChangedSignal.Emit(currentFocusedActor, actor);
172 Toolkit::Control currentlyFocusedControl = Toolkit::Control::DownCast(currentFocusedActor);
173 if( currentlyFocusedControl )
175 // Do we need it to remember if it was previously DISABLED?
176 currentlyFocusedControl.SetProperty(DevelControl::Property::STATE, DevelControl::NORMAL );
177 currentlyFocusedControl.ClearKeyInputFocus();
180 DALI_LOG_INFO( gLogFilter, Debug::General, "[%s:%d] Focus Changed\n", __FUNCTION__, __LINE__);
182 // Save the current focused actor
183 mCurrentFocusActor = actor.GetId();
185 Toolkit::Control newlyFocusedControl = Toolkit::Control::DownCast(actor);
186 if( newlyFocusedControl )
188 newlyFocusedControl.SetProperty(DevelControl::Property::STATE, DevelControl::FOCUSED );
189 newlyFocusedControl.SetKeyInputFocus();
192 // Push Current Focused Actor to FocusHistory
193 mFocusHistory.PushBack( &actor.GetBaseObject() );
195 // Delete first element before add new element when Stack is full.
196 if( mFocusHistory.Count() > MAX_HISTORY_AMOUNT )
198 FocusStackIterator beginPos = mFocusHistory.Begin();
199 mFocusHistory.Erase( beginPos );
202 DALI_LOG_INFO( gLogFilter, Debug::General, "[%s:%d] SUCCEED\n", __FUNCTION__, __LINE__);
207 DALI_LOG_WARNING("[%s:%d] FAILED\n", __FUNCTION__, __LINE__);
213 Actor KeyboardFocusManager::GetCurrentFocusActor()
215 Actor rootActor = Stage::GetCurrent().GetRootLayer();
216 return rootActor.FindChildById(mCurrentFocusActor);
219 Actor KeyboardFocusManager::GetCurrentFocusGroup()
221 return GetFocusGroup(GetCurrentFocusActor());
224 void KeyboardFocusManager::MoveFocusBackward()
226 // Find Pre Focused Actor when the list size is more than 1
227 if( mFocusHistory.Count() > 1 )
229 // Delete current focused actor in history
230 FocusStackIterator endPos = mFocusHistory.End();
231 endPos = mFocusHistory.Erase( --endPos );
233 // If pre-focused actors are not on stage, remove them in stack
234 while( !Dali::Actor::DownCast(BaseHandle(mFocusHistory[ mFocusHistory.Count() - 1 ])).OnStage() )
236 endPos = mFocusHistory.Erase( --endPos );
239 // Get pre focused actor
240 BaseObject* object = mFocusHistory[ mFocusHistory.Count() - 1 ];
241 BaseHandle handle( object );
242 Actor preFocusedActor = Dali::Actor::DownCast( handle );
244 // Delete pre focused actor in history because it will pushed again by SetCurrentFocusActor()
245 mFocusHistory.Erase( --endPos );
247 SetCurrentFocusActor( preFocusedActor );
251 bool KeyboardFocusManager::IsLayoutControl(Actor actor) const
253 Toolkit::Control control = Toolkit::Control::DownCast(actor);
254 return control && GetImplementation( control ).IsKeyboardNavigationSupported();
257 Toolkit::Control KeyboardFocusManager::GetParentLayoutControl(Actor actor) const
259 // Get the actor's parent layout control that supports two dimensional keyboard navigation
260 Actor rootActor = Stage::GetCurrent().GetRootLayer();
264 parent = actor.GetParent();
267 while( parent && !IsLayoutControl(parent) && parent != rootActor )
269 parent = parent.GetParent();
272 return Toolkit::Control::DownCast(parent);
275 bool KeyboardFocusManager::MoveFocus(Toolkit::Control::KeyboardFocus::Direction direction)
277 Actor currentFocusActor = GetCurrentFocusActor();
279 bool succeed = false;
281 // Go through the actor's hierarchy until we find a layout control that knows how to move the focus
282 Toolkit::Control parentLayoutControl = GetParentLayoutControl( currentFocusActor );
283 while( parentLayoutControl && !succeed )
285 succeed = DoMoveFocusWithinLayoutControl( parentLayoutControl, currentFocusActor, direction );
286 parentLayoutControl = GetParentLayoutControl( parentLayoutControl );
291 Actor nextFocusableActor;
293 Toolkit::Control currentFocusControl = Toolkit::Control::DownCast(currentFocusActor);
295 // If the current focused actor is a control, then find the next focusable actor via the focusable properties.
296 if( currentFocusControl )
299 Property::Index index = Property::INVALID_INDEX;
300 Property::Value value;
302 // Find property index based upon focus direction
305 case Toolkit::Control::KeyboardFocus::LEFT:
307 index = Toolkit::DevelControl::Property::LEFT_FOCUSABLE_ACTOR_ID;
310 case Toolkit::Control::KeyboardFocus::RIGHT:
312 index = Toolkit::DevelControl::Property::RIGHT_FOCUSABLE_ACTOR_ID;
315 case Toolkit::Control::KeyboardFocus::UP:
317 index = Toolkit::DevelControl::Property::UP_FOCUSABLE_ACTOR_ID;
320 case Toolkit::Control::KeyboardFocus::DOWN:
322 index = Toolkit::DevelControl::Property::DOWN_FOCUSABLE_ACTOR_ID;
329 // If the focusable property is set then determine next focusable actor
330 if( index != Property::INVALID_INDEX)
332 value = currentFocusActor.GetProperty( index );
333 actorId = value.Get<int>();
335 // If actor's id is valid then find actor form actor's id. The actor should be on the stage.
338 if( currentFocusActor.GetParent() )
340 nextFocusableActor = currentFocusActor.GetParent().FindChildById( actorId );
343 if( !nextFocusableActor )
345 nextFocusableActor = Stage::GetCurrent().GetRootLayer().FindChildById( actorId );
351 if( !nextFocusableActor )
353 // If the implementation of CustomAlgorithmInterface is provided then the PreFocusChangeSignal is no longer emitted.
354 if( mCustomAlgorithmInterface )
356 mIsWaitingKeyboardFocusChangeCommit = true;
357 nextFocusableActor = mCustomAlgorithmInterface->GetNextFocusableActor( currentFocusActor, Actor(), direction );
358 mIsWaitingKeyboardFocusChangeCommit = false;
360 else if( !mPreFocusChangeSignal.Empty() )
362 // Don't know how to move the focus further. The application needs to tell us which actor to move the focus to
363 mIsWaitingKeyboardFocusChangeCommit = true;
364 nextFocusableActor = mPreFocusChangeSignal.Emit( currentFocusActor, Actor(), direction );
365 mIsWaitingKeyboardFocusChangeCommit = false;
369 if( nextFocusableActor && nextFocusableActor.IsKeyboardFocusable() )
371 // Whether the next focusable actor is a layout control
372 if( IsLayoutControl( nextFocusableActor ) )
374 // If so, move the focus inside it.
375 Toolkit::Control layoutControl = Toolkit::Control::DownCast( nextFocusableActor) ;
376 succeed = DoMoveFocusWithinLayoutControl( layoutControl, currentFocusActor, direction );
380 // Otherwise, just set focus to the next focusable actor
381 succeed = SetCurrentFocusActor( nextFocusableActor );
389 bool KeyboardFocusManager::DoMoveFocusWithinLayoutControl(Toolkit::Control control, Actor actor, Toolkit::Control::KeyboardFocus::Direction direction)
391 // Ask the control for the next actor to focus
392 Actor nextFocusableActor = GetImplementation( control ).GetNextKeyboardFocusableActor(actor, direction, mFocusGroupLoopEnabled);
393 if(nextFocusableActor)
395 if(!nextFocusableActor.IsKeyboardFocusable())
397 // If the actor is not focusable, ask the same layout control for the next actor to focus
398 return DoMoveFocusWithinLayoutControl(control, nextFocusableActor, direction);
402 Actor currentFocusActor = GetCurrentFocusActor();
403 Actor committedFocusActor = nextFocusableActor;
405 // We will try to move the focus to the actor. Emit a signal to notify the proposed actor to focus
406 // Signal handler can check the proposed actor and return a different actor if it wishes.
407 if( !mPreFocusChangeSignal.Empty() )
409 mIsWaitingKeyboardFocusChangeCommit = true;
410 committedFocusActor = mPreFocusChangeSignal.Emit(currentFocusActor, nextFocusableActor, direction);
411 mIsWaitingKeyboardFocusChangeCommit = false;
414 if (committedFocusActor && committedFocusActor.IsKeyboardFocusable())
416 // Whether the commited focusable actor is a layout control
417 if(IsLayoutControl(committedFocusActor))
419 // If so, move the focus inside it.
420 Toolkit::Control layoutControl = Toolkit::Control::DownCast(committedFocusActor);
421 return DoMoveFocusWithinLayoutControl(layoutControl, currentFocusActor, direction);
425 // Otherwise, just set focus to the next focusable actor
426 if(committedFocusActor == nextFocusableActor)
428 // If the application hasn't changed our proposed actor, we informs the layout control we will
429 // move the focus to what the control returns. The control might wish to perform some actions
430 // before the focus is actually moved.
431 GetImplementation( control ).OnKeyboardFocusChangeCommitted( committedFocusActor );
434 return SetCurrentFocusActor(committedFocusActor);
445 // No more actor can be focused in the given direction within the same layout control.
450 bool KeyboardFocusManager::DoMoveFocusToNextFocusGroup(bool forward)
452 bool succeed = false;
454 // Get the parent layout control of the current focus group
455 Toolkit::Control parentLayoutControl = GetParentLayoutControl(GetCurrentFocusGroup());
457 while(parentLayoutControl && !succeed)
459 // If the current focus group has a parent layout control, we can probably automatically
460 // move the focus to the next focus group in the forward or backward direction.
461 Toolkit::Control::KeyboardFocus::Direction direction = forward ? Toolkit::Control::KeyboardFocus::RIGHT : Toolkit::Control::KeyboardFocus::LEFT;
462 succeed = DoMoveFocusWithinLayoutControl(parentLayoutControl, GetCurrentFocusActor(), direction);
463 parentLayoutControl = GetParentLayoutControl(parentLayoutControl);
466 if(!mFocusGroupChangedSignal.Empty())
468 // Emit a focus group changed signal. The applicaton can move the focus to a new focus group
469 mFocusGroupChangedSignal.Emit(GetCurrentFocusActor(), forward);
475 void KeyboardFocusManager::DoKeyboardEnter(Actor actor)
479 Toolkit::Control control = Toolkit::Control::DownCast( actor );
482 // Notify the control that enter has been pressed on it.
483 GetImplementation( control ).KeyboardEnter();
486 // Send a notification for the actor.
487 if( !mFocusedActorEnterKeySignal.Empty() )
489 mFocusedActorEnterKeySignal.Emit( actor );
494 void KeyboardFocusManager::ClearFocus()
496 Actor actor = GetCurrentFocusActor();
499 if( mFocusIndicatorActor )
501 actor.Remove( mFocusIndicatorActor );
504 // Send notification for the change of focus actor
505 if( !mFocusChangedSignal.Empty() )
507 mFocusChangedSignal.Emit( actor, Actor() );
510 Toolkit::Control currentlyFocusedControl = Toolkit::Control::DownCast( actor );
511 if( currentlyFocusedControl )
513 currentlyFocusedControl.SetProperty( DevelControl::Property::STATE, DevelControl::NORMAL );
514 currentlyFocusedControl.ClearKeyInputFocus();
518 mCurrentFocusActor = 0;
519 mIsFocusIndicatorEnabled = false;
522 void KeyboardFocusManager::SetFocusGroupLoop(bool enabled)
524 mFocusGroupLoopEnabled = enabled;
527 bool KeyboardFocusManager::GetFocusGroupLoop() const
529 return mFocusGroupLoopEnabled;
532 void KeyboardFocusManager::SetAsFocusGroup(Actor actor, bool isFocusGroup)
536 // Create/Set focus group property.
537 actor.RegisterProperty( IS_FOCUS_GROUP_PROPERTY_NAME, isFocusGroup, Property::READ_WRITE );
541 bool KeyboardFocusManager::IsFocusGroup(Actor actor) const
543 // Check whether the actor is a focus group
544 bool isFocusGroup = false;
548 Property::Index propertyIsFocusGroup = actor.GetPropertyIndex(IS_FOCUS_GROUP_PROPERTY_NAME);
549 if(propertyIsFocusGroup != Property::INVALID_INDEX)
551 isFocusGroup = actor.GetProperty<bool>(propertyIsFocusGroup);
558 Actor KeyboardFocusManager::GetFocusGroup(Actor actor)
560 // Go through the actor's hierarchy to check which focus group the actor belongs to
561 while (actor && !IsFocusGroup(actor))
563 actor = actor.GetParent();
569 void KeyboardFocusManager::SetFocusIndicatorActor(Actor indicator)
571 if(mFocusIndicatorActor != indicator)
573 Actor currentFocusActor = GetCurrentFocusActor();
574 if(currentFocusActor)
576 // The new focus indicator should be added to the current focused actor immediately
577 if(mFocusIndicatorActor)
579 currentFocusActor.Remove(mFocusIndicatorActor);
584 currentFocusActor.Add(indicator);
588 mFocusIndicatorActor = indicator;
592 Actor KeyboardFocusManager::GetFocusIndicatorActor()
594 if( ! mFocusIndicatorActor )
596 // Create the default if it hasn't been set and one that's shared by all the keyboard focusable actors
597 mFocusIndicatorActor = Toolkit::ImageView::New( FOCUS_BORDER_IMAGE_PATH );
599 // Apply size constraint to the focus indicator
600 mFocusIndicatorActor.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
603 mFocusIndicatorActor.SetParentOrigin( ParentOrigin::CENTER );
604 mFocusIndicatorActor.SetAnchorPoint( AnchorPoint::CENTER );
605 mFocusIndicatorActor.SetPosition(0.0f, 0.0f);
607 return mFocusIndicatorActor;
610 void KeyboardFocusManager::OnKeyEvent(const KeyEvent& event)
612 AccessibilityAdaptor accessibilityAdaptor = AccessibilityAdaptor::Get();
613 bool isAccessibilityEnabled = accessibilityAdaptor.IsEnabled();
615 Toolkit::AccessibilityManager accessibilityManager = Toolkit::AccessibilityManager::Get();
617 std::string keyName = event.keyPressedName;
619 bool isFocusStartableKey = false;
621 if(event.state == KeyEvent::Down)
623 if (keyName == "Left")
625 if(!isAccessibilityEnabled)
627 if(!mIsFocusIndicatorEnabled)
629 // Show focus indicator
630 mIsFocusIndicatorEnabled = true;
634 // Move the focus towards left
635 MoveFocus(Toolkit::Control::KeyboardFocus::LEFT);
638 isFocusStartableKey = true;
642 // Move the accessibility focus backward
643 accessibilityManager.MoveFocusBackward();
646 else if (keyName == "Right")
648 if(!isAccessibilityEnabled)
650 if(!mIsFocusIndicatorEnabled)
652 // Show focus indicator
653 mIsFocusIndicatorEnabled = true;
657 // Move the focus towards right
658 MoveFocus(Toolkit::Control::KeyboardFocus::RIGHT);
663 // Move the accessibility focus forward
664 accessibilityManager.MoveFocusForward();
667 isFocusStartableKey = true;
669 else if (keyName == "Up" && !isAccessibilityEnabled)
671 if(!mIsFocusIndicatorEnabled)
673 // Show focus indicator
674 mIsFocusIndicatorEnabled = true;
678 // Move the focus towards up
679 MoveFocus(Toolkit::Control::KeyboardFocus::UP);
682 isFocusStartableKey = true;
684 else if (keyName == "Down" && !isAccessibilityEnabled)
686 if(!mIsFocusIndicatorEnabled)
688 // Show focus indicator
689 mIsFocusIndicatorEnabled = true;
693 // Move the focus towards down
694 MoveFocus(Toolkit::Control::KeyboardFocus::DOWN);
697 isFocusStartableKey = true;
699 else if (keyName == "Prior" && !isAccessibilityEnabled)
701 if(!mIsFocusIndicatorEnabled)
703 // Show focus indicator
704 mIsFocusIndicatorEnabled = true;
708 // Move the focus towards the previous page
709 MoveFocus(Toolkit::Control::KeyboardFocus::PAGE_UP);
712 isFocusStartableKey = true;
714 else if (keyName == "Next" && !isAccessibilityEnabled)
716 if(!mIsFocusIndicatorEnabled)
718 // Show focus indicator
719 mIsFocusIndicatorEnabled = true;
723 // Move the focus towards the next page
724 MoveFocus(Toolkit::Control::KeyboardFocus::PAGE_DOWN);
727 isFocusStartableKey = true;
729 else if (keyName == "Tab" && !isAccessibilityEnabled)
731 if(!mIsFocusIndicatorEnabled)
733 // Show focus indicator
734 mIsFocusIndicatorEnabled = true;
738 // "Tab" key changes the focus group in the forward direction and
739 // "Shift-Tab" key changes it in the backward direction.
740 DoMoveFocusToNextFocusGroup(!event.IsShiftModifier());
743 isFocusStartableKey = true;
745 else if (keyName == "space" && !isAccessibilityEnabled)
747 if(!mIsFocusIndicatorEnabled)
749 // Show focus indicator
750 mIsFocusIndicatorEnabled = true;
753 isFocusStartableKey = true;
755 else if (keyName == "" && !isAccessibilityEnabled)
757 // Check the fake key event for evas-plugin case
758 if(!mIsFocusIndicatorEnabled)
760 // Show focus indicator
761 mIsFocusIndicatorEnabled = true;
764 isFocusStartableKey = true;
766 else if (keyName == "Backspace" && !isAccessibilityEnabled)
768 // Emit signal to go back to the previous view???
770 else if (keyName == "Escape" && !isAccessibilityEnabled)
774 else if(event.state == KeyEvent::Up)
776 if (keyName == "Return")
778 if(!mIsFocusIndicatorEnabled && !isAccessibilityEnabled)
780 // Show focus indicator
781 mIsFocusIndicatorEnabled = true;
785 // The focused actor has enter pressed on it
787 if( !isAccessibilityEnabled )
789 actor = GetCurrentFocusActor();
793 actor = accessibilityManager.GetCurrentFocusActor();
798 DoKeyboardEnter( actor );
802 isFocusStartableKey = true;
806 if(isFocusStartableKey && mIsFocusIndicatorEnabled && !isAccessibilityEnabled)
808 Actor actor = GetCurrentFocusActor();
811 // Make sure the focused actor is highlighted
812 actor.Add( GetFocusIndicatorActor() );
816 // No actor is focused but keyboard focus is activated by the key press
817 // Let's try to move the initial focus
818 MoveFocus(Toolkit::Control::KeyboardFocus::RIGHT);
823 void KeyboardFocusManager::OnTouch(const TouchData& touch)
825 // Clear the focus when user touch the screen.
826 // We only do this on a Down event, otherwise the clear action may override a manually focused actor.
827 if( ( touch.GetPointCount() < 1 ) || ( touch.GetState( 0 ) == PointState::DOWN ) )
833 Toolkit::KeyboardFocusManager::PreFocusChangeSignalType& KeyboardFocusManager::PreFocusChangeSignal()
835 return mPreFocusChangeSignal;
838 Toolkit::KeyboardFocusManager::FocusChangedSignalType& KeyboardFocusManager::FocusChangedSignal()
840 return mFocusChangedSignal;
843 Toolkit::KeyboardFocusManager::FocusGroupChangedSignalType& KeyboardFocusManager::FocusGroupChangedSignal()
845 return mFocusGroupChangedSignal;
848 Toolkit::KeyboardFocusManager::FocusedActorEnterKeySignalType& KeyboardFocusManager::FocusedActorEnterKeySignal()
850 return mFocusedActorEnterKeySignal;
853 bool KeyboardFocusManager::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
855 Dali::BaseHandle handle( object );
857 bool connected( true );
858 KeyboardFocusManager* manager = static_cast< KeyboardFocusManager* >( object ); // TypeRegistry guarantees that this is the correct type.
860 if( 0 == strcmp( signalName.c_str(), SIGNAL_PRE_FOCUS_CHANGE ) )
862 manager->PreFocusChangeSignal().Connect( tracker, functor );
864 else if( 0 == strcmp( signalName.c_str(), SIGNAL_FOCUS_CHANGED ) )
866 manager->FocusChangedSignal().Connect( tracker, functor );
868 else if( 0 == strcmp( signalName.c_str(), SIGNAL_FOCUS_GROUP_CHANGED ) )
870 manager->FocusGroupChangedSignal().Connect( tracker, functor );
872 else if( 0 == strcmp( signalName.c_str(), SIGNAL_FOCUSED_ACTOR_ENTER_KEY ) )
874 manager->FocusedActorEnterKeySignal().Connect( tracker, functor );
878 // signalName does not match any signal
885 void KeyboardFocusManager::SetCustomAlgorithm(CustomAlgorithmInterface& interface)
887 mCustomAlgorithmInterface = &interface;
890 } // namespace Internal
892 } // namespace Toolkit