]> git.saurik.com Git - wxWidgets.git/blobdiff - src/propgrid/propgrid.cpp
more avoiding direct struct access
[wxWidgets.git] / src / propgrid / propgrid.cpp
index c494ce97fa729c873064e03a2ac61505c79bf7a0..2b2877276d93ccd5af28f73a413e59c9e8acf165 100644 (file)
@@ -3982,20 +3982,7 @@ void wxPropertyGrid::FreeEditors()
     // Return focus back to canvas from children (this is required at least for
     // GTK+, which, unlike Windows, clears focus when control is destroyed
     // instead of moving it to closest parent).
     // Return focus back to canvas from children (this is required at least for
     // GTK+, which, unlike Windows, clears focus when control is destroyed
     // instead of moving it to closest parent).
-    wxWindow* focus = wxWindow::FindFocus();
-    if ( focus )
-    {
-        wxWindow* parent = focus->GetParent();
-        while ( parent )
-        {
-            if ( parent == this )
-            {
-                SetFocusOnCanvas();
-                break;
-            }
-            parent = parent->GetParent();
-        }
-    }
+    SetFocusOnCanvas();
 
     // Do not free editors immediately if processing events
     if ( m_wndEditor2 )
 
     // Do not free editors immediately if processing events
     if ( m_wndEditor2 )
@@ -4691,7 +4678,24 @@ void wxPropertyGrid::SetVirtualWidth( int width )
 
 void wxPropertyGrid::SetFocusOnCanvas()
 {
 
 void wxPropertyGrid::SetFocusOnCanvas()
 {
-    SetFocus();
+    // To prevent wxPropertyGrid from stealing focus from other controls,
+    // only move focus to the grid if it was already in one if its child
+    // controls.
+    wxWindow* focus = wxWindow::FindFocus();
+    if ( focus )
+    {
+        wxWindow* parent = focus->GetParent();
+        while ( parent )
+        {
+            if ( parent == this )
+            {
+                SetFocus();
+                break;
+            }
+            parent = parent->GetParent();
+        }
+    }
+
     m_editorFocused = 0;
 }
 
     m_editorFocused = 0;
 }
 
@@ -4824,7 +4828,7 @@ bool wxPropertyGrid::HandleMouseClick( int x, unsigned int y, wxMouseEvent &even
                     }
 
                 // Do not Skip() the event after selection has been made.
                     }
 
                 // Do not Skip() the event after selection has been made.
-                // Otherwise default event handling behavior kicks in
+                // Otherwise default event handling behaviour kicks in
                 // and may revert focus back to the main canvas.
                 res = true;
             }
                 // and may revert focus back to the main canvas.
                 res = true;
             }