Fix bug DClick not active on Transition condition or Jump label
authorLaurent Bessard
Wed, 05 Sep 2012 11:27:54 +0200
changeset 759 264637370f8f
parent 758 bb7a881b20cf
child 760 7cadc624cc74
Fix bug DClick not active on Transition condition or Jump label
graphics/SFC_Objects.py
--- a/graphics/SFC_Objects.py	Wed Sep 05 11:23:15 2012 +0200
+++ b/graphics/SFC_Objects.py	Wed Sep 05 11:27:54 2012 +0200
@@ -699,6 +699,20 @@
         if self.Type == "connection":
             self.Condition.UnConnect(delete = self.Parent.GetDrawingMode() == FREEDRAWING_MODE)
     
+    # Returns if the point given is in the bounding box
+    def HitTest(self, pt, connectors=True):
+        if self.Type != "connection":
+            # Calculate the bounding box of the condition outside the transition
+            text_width, text_height = self.ConditionSize
+            text_bbx = wx.Rect(self.Pos.x + self.Size[0] + 5,
+                               self.Pos.y + (self.Size[1] - text_height) / 2,
+                               text_width,
+                               text_height)
+            test_text = text_bbx.InsideXY(pt.x, pt.y)
+        else:
+            test_text = False
+        return test_text or Graphic_Element.HitTest(self, pt, connectors)
+    
     # Refresh the transition bounding box
     def RefreshBoundingBox(self):
         bbx_x, bbx_y, bbx_width, bbx_height = self.Pos.x, self.Pos.y, self.Size[0], self.Size[1]
@@ -1556,6 +1570,16 @@
     def RefreshTargetSize(self):
         self.TargetSize = self.Parent.GetTextExtent(self.Target)
     
+    # Returns if the point given is in the bounding box
+    def HitTest(self, pt, connectors=True):
+        # Calculate the bounding box of the condition outside the transition
+        text_width, text_height = self.TargetSize
+        text_bbx = wx.Rect(self.Pos.x + self.Size[0] + 2,
+                           self.Pos.y + (self.Size[1] - text_height) / 2,
+                           text_width,
+                           text_height)
+        return text_bbx.InsideXY(pt.x, pt.y) or Graphic_Element.HitTest(self, pt, connectors)
+    
     # Refresh the jump bounding box
     def RefreshBoundingBox(self):
         text_width, text_height = self.Parent.GetTextExtent(self.Target)