]> SALOME platform Git repositories - modules/gui.git/blobdiff - src/SALOME_PYQT/SalomePyQt/SalomePyQt.cxx
Salome HOME
SalomePyQt methods activateModule(), activateView() do not work if focus is in other...
[modules/gui.git] / src / SALOME_PYQT / SalomePyQt / SalomePyQt.cxx
index 0cf073967e555024cea8d877b8efb3c3a048d71f..eea2424635e3c813d78e27a9c751af14ac9b8d1c 100644 (file)
@@ -225,6 +225,25 @@ namespace
     \internal
   */
   const char* DEFAULT_SECTION = "SalomePyQt";
+
+  struct Activator
+  {
+    QWidget* myActiveWindow;
+    QWidget* myFocusedWidget;
+    Activator()
+    {
+      myActiveWindow = QApplication::activeWindow();
+      myFocusedWidget = QApplication::focusWidget();
+      QApplication::setActiveWindow( getApplication()->desktop() );
+    }
+    ~Activator()
+    {
+      if ( myActiveWindow )
+       QApplication::setActiveWindow( myActiveWindow );
+      if ( myFocusedWidget )
+       myFocusedWidget->setFocus();
+    }
+  };
 }
 
 /*!
@@ -934,6 +953,7 @@ public:
   virtual void Execute() 
   {
     if ( LightApp_Application* anApp = getApplication() ) {
+      Activator activator;
       myResult = anApp->activateModule( myModuleName );
     }
   }
@@ -3616,6 +3636,7 @@ public:
     SUIT_ViewWindow* wnd = getWnd( myWndId );
     MESSAGE("window id:" << myWndId << " SUIT_ViewWindow*: " << wnd);
     if ( wnd ) {
+      Activator activator;
       wnd->setFocus();
       myResult = true;
     }