[dali_1.2.18] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / focus-manager / keyboard-focus-manager-impl.cpp
1 /*
2  * Copyright (c) 2016 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17
18 // CLASS HEADER
19 #include "keyboard-focus-manager-impl.h"
20
21 // EXTERNAL INCLUDES
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>
34
35 // INTERNAL INCLUDES
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/focus-manager/keyinput-focus-manager.h>
41
42 namespace Dali
43 {
44
45 namespace Toolkit
46 {
47
48 namespace Internal
49 {
50
51 namespace // Unnamed namespace
52 {
53
54 #if defined(DEBUG_ENABLED)
55 Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_KEYBOARD_FOCUS_MANAGER");
56 #endif
57
58 const char* const IS_FOCUS_GROUP_PROPERTY_NAME = "isKeyboardFocusGroup"; // This property will be replaced by a flag in Control.
59
60 const char* const FOCUS_BORDER_IMAGE_PATH = DALI_IMAGE_DIR "keyboard_focus.9.png";
61
62 BaseHandle Create()
63 {
64   BaseHandle handle = KeyboardFocusManager::Get();
65
66   if ( !handle )
67   {
68     SingletonService singletonService( SingletonService::Get() );
69     if ( singletonService )
70     {
71       Toolkit::KeyboardFocusManager manager = Toolkit::KeyboardFocusManager( new Internal::KeyboardFocusManager() );
72       singletonService.Register( typeid( manager ), manager );
73       handle = manager;
74     }
75   }
76
77   return handle;
78 }
79
80 DALI_TYPE_REGISTRATION_BEGIN_CREATE( Toolkit::KeyboardFocusManager, Dali::BaseHandle, Create, true )
81
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 )
86
87 DALI_TYPE_REGISTRATION_END()
88
89 } // unnamed namespace
90
91 Toolkit::KeyboardFocusManager KeyboardFocusManager::Get()
92 {
93   Toolkit::KeyboardFocusManager manager;
94
95   SingletonService singletonService( SingletonService::Get() );
96   if ( singletonService )
97   {
98     // Check whether the keyboard focus manager is already created
99     Dali::BaseHandle handle = singletonService.GetSingleton( typeid( Toolkit::KeyboardFocusManager ) );
100     if(handle)
101     {
102       // If so, downcast the handle of singleton to keyboard focus manager
103       manager = Toolkit::KeyboardFocusManager( dynamic_cast< KeyboardFocusManager* >( handle.GetObjectPtr() ) );
104     }
105   }
106
107   return manager;
108 }
109
110 KeyboardFocusManager::KeyboardFocusManager()
111 : mCurrentFocusActor(0),
112   mFocusIndicatorActor(),
113   mFocusGroupLoopEnabled(false),
114   mIsKeyboardFocusEnabled(false),
115   mIsFocusIndicatorEnabled(false),
116   mIsWaitingKeyboardFocusChangeCommit(false),
117   mSlotDelegate(this)
118 {
119   OnPhysicalKeyboardStatusChanged(PhysicalKeyboard::Get());
120
121   Toolkit::KeyInputFocusManager::Get().UnhandledKeyEventSignal().Connect(mSlotDelegate, &KeyboardFocusManager::OnKeyEvent);
122   Stage::GetCurrent().TouchSignal().Connect( mSlotDelegate, &KeyboardFocusManager::OnTouch );
123   PhysicalKeyboard::Get().StatusChangedSignal().Connect(mSlotDelegate, &KeyboardFocusManager::OnPhysicalKeyboardStatusChanged);
124 }
125
126 KeyboardFocusManager::~KeyboardFocusManager()
127 {
128 }
129
130 bool KeyboardFocusManager::SetCurrentFocusActor( Actor actor )
131 {
132   DALI_ASSERT_DEBUG( !mIsWaitingKeyboardFocusChangeCommit && "Calling this function in the PreFocusChangeSignal callback?" );
133
134   if( actor )
135   {
136     return DoSetCurrentFocusActor( actor.GetId() );
137   }
138
139   return false;
140 }
141
142 bool KeyboardFocusManager::DoSetCurrentFocusActor( const unsigned int actorID )
143 {
144   Actor rootActor = Stage::GetCurrent().GetRootLayer();
145   Actor actor = rootActor.FindChildById( actorID );
146   bool success = false;
147
148   // Check whether the actor is in the stage and is keyboard focusable.
149   if( actor && actor.IsKeyboardFocusable() )
150   {
151     mIsFocusIndicatorEnabled = true;
152     // Draw the focus indicator upon the focused actor when PhysicalKeyboard is attached
153     if( mIsKeyboardFocusEnabled )
154     {
155       actor.Add( GetFocusIndicatorActor() );
156     }
157     // Send notification for the change of focus actor
158     if( !mFocusChangedSignal.Empty() )
159     {
160       mFocusChangedSignal.Emit(GetCurrentFocusActor(), actor);
161     }
162
163     DALI_LOG_INFO( gLogFilter, Debug::General, "[%s:%d] Focus Changed\n", __FUNCTION__, __LINE__);
164
165     // Save the current focused actor
166     mCurrentFocusActor = actorID;
167
168     DALI_LOG_INFO( gLogFilter, Debug::General, "[%s:%d] SUCCEED\n", __FUNCTION__, __LINE__);
169     success = true;
170   }
171   else
172   {
173     DALI_LOG_WARNING("[%s:%d] FAILED\n", __FUNCTION__, __LINE__);
174   }
175
176   return success;
177 }
178
179 Actor KeyboardFocusManager::GetCurrentFocusActor()
180 {
181   Actor rootActor = Stage::GetCurrent().GetRootLayer();
182   return rootActor.FindChildById(mCurrentFocusActor);
183 }
184
185 Actor KeyboardFocusManager::GetCurrentFocusGroup()
186 {
187   return GetFocusGroup(GetCurrentFocusActor());
188 }
189
190 bool KeyboardFocusManager::IsLayoutControl(Actor actor) const
191 {
192   Toolkit::Control control = Toolkit::Control::DownCast(actor);
193   return control && GetImplementation( control ).IsKeyboardNavigationSupported();
194 }
195
196 Toolkit::Control KeyboardFocusManager::GetParentLayoutControl(Actor actor) const
197 {
198   // Get the actor's parent layout control that supports two dimensional keyboard navigation
199   Actor rootActor = Stage::GetCurrent().GetRootLayer();
200   Actor parent;
201   if(actor)
202   {
203     parent = actor.GetParent();
204   }
205
206   while( parent && !IsLayoutControl(parent) && parent != rootActor )
207   {
208     parent = parent.GetParent();
209   }
210
211   return Toolkit::Control::DownCast(parent);
212 }
213
214 bool KeyboardFocusManager::MoveFocus(Toolkit::Control::KeyboardFocus::Direction direction)
215 {
216   Actor currentFocusActor = GetCurrentFocusActor();
217
218   bool succeed = false;
219
220   // Go through the actor's hierarchy until we find a layout control that knows how to move the focus
221   Toolkit::Control parentLayoutControl = GetParentLayoutControl(currentFocusActor);
222   while(parentLayoutControl && !succeed)
223   {
224     succeed = DoMoveFocusWithinLayoutControl(parentLayoutControl, currentFocusActor, direction);
225     parentLayoutControl = GetParentLayoutControl(parentLayoutControl);
226   }
227
228   if(!succeed && !mPreFocusChangeSignal.Empty())
229   {
230     // Don't know how to move the focus further. The application needs to tell us which actor to move the focus to
231     mIsWaitingKeyboardFocusChangeCommit = true;
232     Actor nextFocusableActor = mPreFocusChangeSignal.Emit(currentFocusActor, Actor(), direction);
233     mIsWaitingKeyboardFocusChangeCommit = false;
234
235     if ( nextFocusableActor && nextFocusableActor.IsKeyboardFocusable() )
236     {
237       // Whether the next focusable actor is a layout control
238       if(IsLayoutControl(nextFocusableActor))
239       {
240         // If so, move the focus inside it.
241         Toolkit::Control layoutControl = Toolkit::Control::DownCast(nextFocusableActor);
242         succeed = DoMoveFocusWithinLayoutControl(layoutControl, currentFocusActor, direction);
243       }
244       else
245       {
246         // Otherwise, just set focus to the next focusable actor
247         succeed = SetCurrentFocusActor(nextFocusableActor);
248       }
249     }
250   }
251
252   return succeed;
253 }
254
255 bool KeyboardFocusManager::DoMoveFocusWithinLayoutControl(Toolkit::Control control, Actor actor, Toolkit::Control::KeyboardFocus::Direction direction)
256 {
257   // Ask the control for the next actor to focus
258   Actor nextFocusableActor = GetImplementation( control ).GetNextKeyboardFocusableActor(actor, direction, mFocusGroupLoopEnabled);
259   if(nextFocusableActor)
260   {
261     if(!nextFocusableActor.IsKeyboardFocusable())
262     {
263       // If the actor is not focusable, ask the same layout control for the next actor to focus
264       return DoMoveFocusWithinLayoutControl(control, nextFocusableActor, direction);
265     }
266     else
267     {
268       Actor currentFocusActor = GetCurrentFocusActor();
269       Actor committedFocusActor = nextFocusableActor;
270
271       // We will try to move the focus to the actor. Emit a signal to notify the proposed actor to focus
272       // Signal handler can check the proposed actor and return a different actor if it wishes.
273       if( !mPreFocusChangeSignal.Empty() )
274       {
275         mIsWaitingKeyboardFocusChangeCommit = true;
276         committedFocusActor = mPreFocusChangeSignal.Emit(currentFocusActor, nextFocusableActor, direction);
277         mIsWaitingKeyboardFocusChangeCommit = false;
278       }
279
280       if (committedFocusActor && committedFocusActor.IsKeyboardFocusable())
281       {
282         // Whether the commited focusable actor is a layout control
283         if(IsLayoutControl(committedFocusActor))
284         {
285           // If so, move the focus inside it.
286           Toolkit::Control layoutControl = Toolkit::Control::DownCast(committedFocusActor);
287           return DoMoveFocusWithinLayoutControl(layoutControl, currentFocusActor, direction);
288         }
289         else
290         {
291           // Otherwise, just set focus to the next focusable actor
292           if(committedFocusActor == nextFocusableActor)
293           {
294             // If the application hasn't changed our proposed actor, we informs the layout control we will
295             // move the focus to what the control returns. The control might wish to perform some actions
296             // before the focus is actually moved.
297             GetImplementation( control ).OnKeyboardFocusChangeCommitted( committedFocusActor );
298           }
299
300           return SetCurrentFocusActor(committedFocusActor);
301         }
302       }
303       else
304       {
305         return false;
306       }
307     }
308   }
309   else
310   {
311     // No more actor can be focused in the given direction within the same layout control.
312     return false;
313   }
314 }
315
316 bool KeyboardFocusManager::DoMoveFocusToNextFocusGroup(bool forward)
317 {
318   bool succeed = false;
319
320   // Get the parent layout control of the current focus group
321   Toolkit::Control parentLayoutControl = GetParentLayoutControl(GetCurrentFocusGroup());
322
323   while(parentLayoutControl && !succeed)
324   {
325     // If the current focus group has a parent layout control, we can probably automatically
326     // move the focus to the next focus group in the forward or backward direction.
327     Toolkit::Control::KeyboardFocus::Direction direction = forward ? Toolkit::Control::KeyboardFocus::RIGHT : Toolkit::Control::KeyboardFocus::LEFT;
328     succeed = DoMoveFocusWithinLayoutControl(parentLayoutControl, GetCurrentFocusActor(), direction);
329     parentLayoutControl = GetParentLayoutControl(parentLayoutControl);
330   }
331
332   if(!mFocusGroupChangedSignal.Empty())
333   {
334     // Emit a focus group changed signal. The applicaton can move the focus to a new focus group
335     mFocusGroupChangedSignal.Emit(GetCurrentFocusActor(), forward);
336   }
337
338   return succeed;
339 }
340
341 void KeyboardFocusManager::DoKeyboardEnter(Actor actor)
342 {
343   if( actor )
344   {
345     Toolkit::Control control = Toolkit::Control::DownCast( actor );
346     if( control )
347     {
348       // Notify the control that enter has been pressed on it.
349       GetImplementation( control ).KeyboardEnter();
350     }
351
352     // Send a notification for the actor.
353     if( !mFocusedActorEnterKeySignal.Empty() )
354     {
355       mFocusedActorEnterKeySignal.Emit( actor );
356     }
357   }
358 }
359
360 void KeyboardFocusManager::ClearFocus()
361 {
362   Actor actor = GetCurrentFocusActor();
363   if(actor)
364   {
365     if(mFocusIndicatorActor)
366     {
367       actor.Remove(mFocusIndicatorActor);
368     }
369
370     // Send notification for the change of focus actor
371     if( !mFocusChangedSignal.Empty() )
372     {
373       mFocusChangedSignal.Emit(actor, Actor());
374     }
375   }
376
377   mCurrentFocusActor = 0;
378   mIsFocusIndicatorEnabled = false;
379 }
380
381 void KeyboardFocusManager::SetFocusGroupLoop(bool enabled)
382 {
383   mFocusGroupLoopEnabled = enabled;
384 }
385
386 bool KeyboardFocusManager::GetFocusGroupLoop() const
387 {
388   return mFocusGroupLoopEnabled;
389 }
390
391 void KeyboardFocusManager::SetAsFocusGroup(Actor actor, bool isFocusGroup)
392 {
393   if(actor)
394   {
395     // Create/Set focus group property.
396     actor.RegisterProperty( IS_FOCUS_GROUP_PROPERTY_NAME, isFocusGroup, Property::READ_WRITE );
397   }
398 }
399
400 bool KeyboardFocusManager::IsFocusGroup(Actor actor) const
401 {
402   // Check whether the actor is a focus group
403   bool isFocusGroup = false;
404
405   if(actor)
406   {
407     Property::Index propertyIsFocusGroup = actor.GetPropertyIndex(IS_FOCUS_GROUP_PROPERTY_NAME);
408     if(propertyIsFocusGroup != Property::INVALID_INDEX)
409     {
410       isFocusGroup = actor.GetProperty<bool>(propertyIsFocusGroup);
411     }
412   }
413
414   return isFocusGroup;
415 }
416
417 Actor KeyboardFocusManager::GetFocusGroup(Actor actor)
418 {
419   // Go through the actor's hierarchy to check which focus group the actor belongs to
420   while (actor && !IsFocusGroup(actor))
421   {
422     actor = actor.GetParent();
423   }
424
425   return actor;
426 }
427
428 void KeyboardFocusManager::SetFocusIndicatorActor(Actor indicator)
429 {
430   if(mFocusIndicatorActor != indicator)
431   {
432     Actor currentFocusActor = GetCurrentFocusActor();
433     if(currentFocusActor)
434     {
435       // The new focus indicator should be added to the current focused actor immediately
436       if(mFocusIndicatorActor)
437       {
438         currentFocusActor.Remove(mFocusIndicatorActor);
439       }
440
441       if(indicator)
442       {
443         currentFocusActor.Add(indicator);
444       }
445     }
446
447     mFocusIndicatorActor = indicator;
448   }
449 }
450
451 Actor KeyboardFocusManager::GetFocusIndicatorActor()
452 {
453   if( ! mFocusIndicatorActor )
454   {
455     // Create the default if it hasn't been set and one that's shared by all the keyboard focusable actors
456     mFocusIndicatorActor = Toolkit::ImageView::New( FOCUS_BORDER_IMAGE_PATH );
457     mFocusIndicatorActor.SetParentOrigin( ParentOrigin::CENTER );
458
459     // Apply size constraint to the focus indicator
460     mFocusIndicatorActor.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
461   }
462
463   return mFocusIndicatorActor;
464 }
465
466 void KeyboardFocusManager::OnPhysicalKeyboardStatusChanged(PhysicalKeyboard keyboard)
467 {
468   mIsKeyboardFocusEnabled = keyboard.IsAttached();
469
470   if(mIsKeyboardFocusEnabled)
471   {
472     // Show indicator when keyboard focus turned on if there is focused actor.
473     Actor actor = GetCurrentFocusActor();
474     if(actor)
475     {
476       actor.Add( GetFocusIndicatorActor() );
477     }
478     mIsFocusIndicatorEnabled = true;
479   }
480   else
481   {
482     // Hide indicator when keyboard focus turned off
483     Actor actor = GetCurrentFocusActor();
484     if( actor && mFocusIndicatorActor )
485     {
486       actor.Remove( mFocusIndicatorActor );
487     }
488     mIsFocusIndicatorEnabled = false;
489   }
490 }
491
492 void KeyboardFocusManager::OnKeyEvent(const KeyEvent& event)
493 {
494   if(!mIsKeyboardFocusEnabled)
495   {
496     return;
497   }
498
499   AccessibilityAdaptor accessibilityAdaptor = AccessibilityAdaptor::Get();
500   bool isAccessibilityEnabled = accessibilityAdaptor.IsEnabled();
501
502   Toolkit::AccessibilityManager accessibilityManager = Toolkit::AccessibilityManager::Get();
503
504   std::string keyName = event.keyPressedName;
505
506   bool isFocusStartableKey = false;
507
508   if(event.state == KeyEvent::Down)
509   {
510     if (keyName == "Left")
511     {
512       if(!isAccessibilityEnabled)
513       {
514         if(!mIsFocusIndicatorEnabled)
515         {
516           // Show focus indicator
517           mIsFocusIndicatorEnabled = true;
518         }
519         else
520         {
521           // Move the focus towards left
522           MoveFocus(Toolkit::Control::KeyboardFocus::LEFT);
523         }
524
525         isFocusStartableKey = true;
526       }
527       else
528       {
529         // Move the accessibility focus backward
530         accessibilityManager.MoveFocusBackward();
531       }
532     }
533     else if (keyName == "Right")
534     {
535       if(!isAccessibilityEnabled)
536       {
537         if(!mIsFocusIndicatorEnabled)
538         {
539           // Show focus indicator
540           mIsFocusIndicatorEnabled = true;
541         }
542         else
543         {
544           // Move the focus towards right
545           MoveFocus(Toolkit::Control::KeyboardFocus::RIGHT);
546         }
547       }
548       else
549       {
550         // Move the accessibility focus forward
551         accessibilityManager.MoveFocusForward();
552       }
553
554       isFocusStartableKey = true;
555     }
556     else if (keyName == "Up" && !isAccessibilityEnabled)
557     {
558       if(!mIsFocusIndicatorEnabled)
559       {
560         // Show focus indicator
561         mIsFocusIndicatorEnabled = true;
562       }
563       else
564       {
565         // Move the focus towards up
566         MoveFocus(Toolkit::Control::KeyboardFocus::UP);
567       }
568
569       isFocusStartableKey = true;
570     }
571     else if (keyName == "Down" && !isAccessibilityEnabled)
572     {
573       if(!mIsFocusIndicatorEnabled)
574       {
575         // Show focus indicator
576         mIsFocusIndicatorEnabled = true;
577       }
578       else
579       {
580         // Move the focus towards down
581         MoveFocus(Toolkit::Control::KeyboardFocus::DOWN);
582       }
583
584       isFocusStartableKey = true;
585     }
586     else if (keyName == "Tab" && !isAccessibilityEnabled)
587     {
588       if(!mIsFocusIndicatorEnabled)
589       {
590         // Show focus indicator
591         mIsFocusIndicatorEnabled = true;
592       }
593       else
594       {
595         // "Tab" key changes the focus group in the forward direction and
596         // "Shift-Tab" key changes it in the backward direction.
597         DoMoveFocusToNextFocusGroup(!event.IsShiftModifier());
598       }
599
600       isFocusStartableKey = true;
601     }
602     else if (keyName == "space" && !isAccessibilityEnabled)
603     {
604       if(!mIsFocusIndicatorEnabled)
605       {
606         // Show focus indicator
607         mIsFocusIndicatorEnabled = true;
608       }
609
610       isFocusStartableKey = true;
611     }
612     else if (keyName == "" && !isAccessibilityEnabled)
613     {
614       // Check the fake key event for evas-plugin case
615       if(!mIsFocusIndicatorEnabled)
616       {
617         // Show focus indicator
618         mIsFocusIndicatorEnabled = true;
619       }
620
621       isFocusStartableKey = true;
622     }
623     else if (keyName == "Backspace" && !isAccessibilityEnabled)
624     {
625       // Emit signal to go back to the previous view???
626     }
627   }
628   else if(event.state == KeyEvent::Up)
629   {
630     if (keyName == "Return")
631     {
632       if(!mIsFocusIndicatorEnabled && !isAccessibilityEnabled)
633       {
634         // Show focus indicator
635         mIsFocusIndicatorEnabled = true;
636       }
637       else
638       {
639         // The focused actor has enter pressed on it
640         Actor actor;
641         if( !isAccessibilityEnabled )
642         {
643           actor = GetCurrentFocusActor();
644         }
645         else
646         {
647           actor = accessibilityManager.GetCurrentFocusActor();
648         }
649
650         if( actor )
651         {
652           DoKeyboardEnter( actor );
653         }
654       }
655
656       isFocusStartableKey = true;
657     }
658   }
659
660   if(isFocusStartableKey && mIsFocusIndicatorEnabled && !isAccessibilityEnabled)
661   {
662     Actor actor = GetCurrentFocusActor();
663     if( actor )
664     {
665       // Make sure the focused actor is highlighted
666       actor.Add( GetFocusIndicatorActor() );
667     }
668     else
669     {
670       // No actor is focused but keyboard focus is activated by the key press
671       // Let's try to move the initial focus
672       MoveFocus(Toolkit::Control::KeyboardFocus::RIGHT);
673     }
674   }
675 }
676
677 void KeyboardFocusManager::OnTouch(const TouchData& touch)
678 {
679   // Clear the focus when user touch the screen.
680   // We only do this on a Down event, otherwise the clear action may override a manually focused actor.
681   if( ( touch.GetPointCount() < 1 ) || ( touch.GetState( 0 ) == PointState::DOWN ) )
682   {
683     ClearFocus();
684   }
685 }
686
687 Toolkit::KeyboardFocusManager::PreFocusChangeSignalType& KeyboardFocusManager::PreFocusChangeSignal()
688 {
689   return mPreFocusChangeSignal;
690 }
691
692 Toolkit::KeyboardFocusManager::FocusChangedSignalType& KeyboardFocusManager::FocusChangedSignal()
693 {
694   return mFocusChangedSignal;
695 }
696
697 Toolkit::KeyboardFocusManager::FocusGroupChangedSignalType& KeyboardFocusManager::FocusGroupChangedSignal()
698 {
699   return mFocusGroupChangedSignal;
700 }
701
702 Toolkit::KeyboardFocusManager::FocusedActorEnterKeySignalType& KeyboardFocusManager::FocusedActorEnterKeySignal()
703 {
704   return mFocusedActorEnterKeySignal;
705 }
706
707 bool KeyboardFocusManager::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
708 {
709   Dali::BaseHandle handle( object );
710
711   bool connected( true );
712   KeyboardFocusManager* manager = static_cast< KeyboardFocusManager* >( object ); // TypeRegistry guarantees that this is the correct type.
713
714   if( 0 == strcmp( signalName.c_str(), SIGNAL_PRE_FOCUS_CHANGE ) )
715   {
716     manager->PreFocusChangeSignal().Connect( tracker, functor );
717   }
718   else if( 0 == strcmp( signalName.c_str(), SIGNAL_FOCUS_CHANGED ) )
719   {
720     manager->FocusChangedSignal().Connect( tracker, functor );
721   }
722   else if( 0 == strcmp( signalName.c_str(), SIGNAL_FOCUS_GROUP_CHANGED ) )
723   {
724     manager->FocusGroupChangedSignal().Connect( tracker, functor );
725   }
726   else if( 0 == strcmp( signalName.c_str(), SIGNAL_FOCUSED_ACTOR_ENTER_KEY ) )
727   {
728     manager->FocusedActorEnterKeySignal().Connect( tracker, functor );
729   }
730   else
731   {
732     // signalName does not match any signal
733     connected = false;
734   }
735
736   return connected;
737 }
738
739 } // namespace Internal
740
741 } // namespace Toolkit
742
743 } // namespace Dali