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