]> git.saurik.com Git - wxWidgets.git/blobdiff - wxPython/samples/ide/activegrid/tool/AbstractEditor.py
More updates to the docview library modules and sample apps from the
[wxWidgets.git] / wxPython / samples / ide / activegrid / tool / AbstractEditor.py
index 1361b422e8b495e6f60357106ad1e59976af883b..8369738428b2469d4decdf5227b7e32d6784bbb4 100644 (file)
@@ -66,13 +66,18 @@ class CanvasView(wx.lib.docview.View):
         if activate and self._canvas:
             # In MDI mode just calling set focus doesn't work and in SDI mode using CallAfter causes an endless loop
             if self.GetDocumentManager().GetFlags() & wx.lib.docview.DOC_SDI:
-                self._canvas.SetFocus()
+                self.SetFocus()
             else:
-                wx.CallAfter(self._canvas.SetFocus)
+                wx.CallAfter(self.SetFocus)
+
+
+    def SetFocus(self):
+        if self._canvas:
+            self._canvas.SetFocus()
 
 
     def OnFocus(self, event):
-        self._canvas.SetFocus()
+        self.SetFocus()
         self.FocusColorPropertyShape(True)
         event.Skip()
 
@@ -82,6 +87,17 @@ class CanvasView(wx.lib.docview.View):
         event.Skip()
 
 
+    def HasFocus(self):
+        winWithFocus = wx.Window.FindFocus()
+        if not winWithFocus:
+            return False
+        while winWithFocus:
+            if winWithFocus == self._canvas:
+                return True
+            winWithFocus = winWithFocus.GetParent()
+        return False
+
+
     def OnClose(self, deleteWindow = True):
         statusC = wx.GetApp().CloseChildDocuments(self.GetDocument())
         statusP = wx.lib.docview.View.OnClose(self, deleteWindow = deleteWindow)
@@ -528,7 +544,10 @@ class CanvasView(wx.lib.docview.View):
 
         # draw new selection
         if self._propShape and self._propShape in self._diagram.GetShapeList():
-            self._propShape.SetBrush(SELECT_BRUSH)
+            if self.HasFocus():
+                self._propShape.SetBrush(SELECT_BRUSH)
+            else:
+                self._propShape.SetBrush(INACTIVE_SELECT_BRUSH)
             if (self._propShape._textColourName in ["BLACK", "WHITE"]):  # Would use GetTextColour() but it is broken
                 self._propShape.SetTextColour("WHITE", 0)
             self._propShape.Draw(dc)