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