- // TODO: Get FocusIndicatorEnable constant from stylesheet to set mIsFocusIndicatorEnabled.
- Stage::GetCurrent().KeyEventSignal().Connect( mSlotDelegate, &KeyboardFocusManager::OnKeyEvent);
- Stage::GetCurrent().TouchSignal().Connect( mSlotDelegate, &KeyboardFocusManager::OnTouch );
+ if( Adaptor::IsAvailable() )
+ {
+ // Retrieve all the existing scene holders
+ Dali::SceneHolderList sceneHolders = Adaptor::Get().GetSceneHolders();
+ for( auto iter = sceneHolders.begin(); iter != sceneHolders.end(); ++iter )
+ {
+ ( *iter ).KeyEventSignal().Connect( mSlotDelegate, &KeyboardFocusManager::OnKeyEvent );
+ ( *iter ).TouchSignal().Connect( mSlotDelegate, &KeyboardFocusManager::OnTouch );
+ Dali::Window window = DevelWindow::DownCast( *iter );
+ if( window )
+ {
+ window.FocusChangeSignal().Connect( mSlotDelegate, &KeyboardFocusManager::OnWindowFocusChanged);
+ }
+ }
+
+ // Get notified when any new scene holder is created afterwards
+ Adaptor::Get().WindowCreatedSignal().Connect( mSlotDelegate, &KeyboardFocusManager::OnSceneHolderCreated );
+ }
+}
+
+void KeyboardFocusManager::OnSceneHolderCreated( Dali::Integration::SceneHolder& sceneHolder )
+{
+ sceneHolder.KeyEventSignal().Connect( mSlotDelegate, &KeyboardFocusManager::OnKeyEvent );
+ sceneHolder.TouchSignal().Connect( mSlotDelegate, &KeyboardFocusManager::OnTouch );
+ Dali::Window window = DevelWindow::DownCast( sceneHolder );
+ if( window )
+ {
+ window.FocusChangeSignal().Connect( mSlotDelegate, &KeyboardFocusManager::OnWindowFocusChanged);
+ }