Viewer.py
changeset 243 c5da8b706cde
parent 239 d12779e971bd
child 249 d8425712acef
--- a/Viewer.py	Wed Aug 27 16:55:16 2008 +0200
+++ b/Viewer.py	Wed Aug 27 16:56:25 2008 +0200
@@ -848,9 +848,9 @@
                 return element
         return None
     
-    def FindBlockConnector(self, pos, exclude = True):
+    def FindBlockConnector(self, pos, direction = None, exclude = True):
         for block in self.Blocks:
-            result = block.TestConnector(pos, exclude)
+            result = block.TestConnector(pos, direction, exclude)
             if result:
                 return result
         return None
@@ -1116,6 +1116,8 @@
                 if self.DrawingWire:
                     self.DrawingWire = False
                     if self.SelectedElement is not None:
+                        if element is None or element.TestHandle(pos) == (0, 0):
+                            connector = self.FindBlockConnector(pos, self.SelectedElement.GetConnectionDirection())
                         if connector:
                             event.Dragging = lambda : True
                             self.SelectedElement.OnMotion(event, self.GetLogicalDC(), self.Scaling)
@@ -1211,7 +1213,7 @@
             dc = self.GetLogicalDC()
             if self.DrawingWire:
                 pos = event.GetLogicalPosition(dc)
-                connector = self.FindBlockConnector(pos)
+                connector = self.FindBlockConnector(pos, self.SelectedElement.GetConnectionDirection())
                 if self.SelectedElement.EndConnected is not None:
                     self.DrawingWire = False
                     self.SelectedElement.StartConnected.HighlightParentBlock(False)
@@ -1287,7 +1289,7 @@
             self.rubberBand.OnMotion(event, dc, self.Scaling)
         elif self.Mode == MODE_SELECTION and self.SelectedElement:
             if self.DrawingWire:
-                connector = self.FindBlockConnector(pos, False)
+                connector = self.FindBlockConnector(pos, self.SelectedElement.GetConnectionDirection(), False)
                 if not connector or self.SelectedElement.EndConnected == None:
                     self.SelectedElement.ResetPoints()
                     movex, movey = self.SelectedElement.OnMotion(event, dc, self.Scaling)