editors/Viewer.py
changeset 1544 2969c2123105
parent 1498 b11045a2f17c
child 1556 32e9d0ef30dc
--- a/editors/Viewer.py	Fri Oct 14 18:04:22 2016 +0300
+++ b/editors/Viewer.py	Tue Oct 18 17:44:08 2016 +0300
@@ -1462,12 +1462,20 @@
         return None
 
     def FindBlockConnector(self, pos, direction = None, exclude = None):
+        result, error = self.FindBlockConnectorWithError(pos, direction, exclude)
+        return result
+
+    def FindBlockConnectorWithError(self, pos, direction = None, exclude = None):
+        error = False        
         for block in self.Blocks.itervalues():
-            result = block.TestConnector(pos, direction, exclude)
-            if result:
-                return result
-        return None
-
+            connector = block.TestConnector(pos, direction, exclude)
+            if connector:
+                avail, error = connector.ConnectionAvailable(direction, exclude)
+                if not avail:
+                    connector = None
+                return connector, error
+        return None, error
+    
     def FindElementById(self, id):
         block = self.Blocks.get(id, None)
         if block is not None:
@@ -2273,7 +2281,8 @@
                 self.rubberBand.OnMotion(event, dc, self.Scaling)
             elif not self.Debug and self.Mode == MODE_SELECTION and self.SelectedElement is not None:
                 if self.DrawingWire:
-                    connector = self.FindBlockConnector(pos, self.SelectedElement.GetConnectionDirection(), self.SelectedElement.EndConnected)
+                    connector, errorHighlight = self.FindBlockConnectorWithError(pos, self.SelectedElement.GetConnectionDirection(), self.SelectedElement.EndConnected)
+                    self.SelectedElement.ErrHighlight = errorHighlight;
                     if not connector or self.SelectedElement.EndConnected == None:
                         self.SelectedElement.ResetPoints()
                         movex, movey = self.SelectedElement.OnMotion(event, dc, self.Scaling)