Connect KeyEventGeneratedSignal for Get KeyEvent
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / focus-manager / keyinput-focus-manager-impl.cpp
index f188281..71bc352 100644 (file)
@@ -23,6 +23,8 @@
 #include <dali/public-api/actors/layer.h>
 #include <dali/public-api/common/stage.h>
 #include <dali/devel-api/common/stage-devel.h>
+#include <dali/devel-api/adaptor-framework/window-devel.h>
+#include <dali/integration-api/adaptors/adaptor.h>
 
 // INTERNAL INCLUDES
 #include <dali-toolkit/public-api/controls/control-impl.h>
@@ -50,13 +52,26 @@ KeyInputFocusManager::KeyInputFocusManager()
 : mSlotDelegate( this ),
   mCurrentFocusControl()
 {
-  DevelStage::KeyEventGeneratedSignal( Stage::GetCurrent() ).Connect(mSlotDelegate, &KeyInputFocusManager::OnKeyEvent);
+  // Retrieve all the existing widnows
+  Dali::WindowContainer windows = Adaptor::Get().GetWindows();
+  for ( auto iter = windows.begin(); iter != windows.end(); ++iter )
+  {
+    DevelWindow::KeyEventGeneratedSignal( *iter ).Connect( mSlotDelegate, &KeyInputFocusManager::OnKeyEvent);
+  }
+
+  // Get notified when any new window is created afterwards
+  Adaptor::Get().WindowCreatedSignal().Connect( mSlotDelegate, &KeyInputFocusManager::OnWindowCreated);
 }
 
 KeyInputFocusManager::~KeyInputFocusManager()
 {
 }
 
+void KeyInputFocusManager::OnWindowCreated( Dali::Window& window )
+{
+  DevelWindow::KeyEventGeneratedSignal( window ).Connect( mSlotDelegate, &KeyInputFocusManager::OnKeyEvent);
+}
+
 void KeyInputFocusManager::SetFocus( Toolkit::Control control )
 {
   if( !control )