Fixed MouseWheel behavior in DebugVariablePanel, change graph range only if CTRL is pressed
authorLaurent Bessard
Thu, 18 Apr 2013 20:38:47 +0200
changeset 1040 af8a1aee3584
parent 1039 7bd88ac7b871
child 1041 736ec395399a
Fixed MouseWheel behavior in DebugVariablePanel, change graph range only if CTRL is pressed
controls/DebugVariablePanel.py
--- a/controls/DebugVariablePanel.py	Thu Apr 18 12:14:05 2013 +0200
+++ b/controls/DebugVariablePanel.py	Thu Apr 18 20:38:47 2013 +0200
@@ -139,6 +139,7 @@
             self.MaxValue = None
         else:
             self.Data = None
+        self.Value = ""
     
     def IsNumVariable(self):
         return (self.Parent.IsNumType(self.VariableType) or 
@@ -1149,13 +1150,14 @@
                             self.ParentWindow.ForceRefresh()
         
         def OnCanvasScroll(self, event):
-            if event.inaxes is not None:
+            if event.inaxes is not None and event.guiEvent.ControlDown():
                 if self.GraphType == GRAPH_ORTHOGONAL:
                     start_tick, end_tick = self.ParentWindow.GetRange()
                     tick = (start_tick + end_tick) / 2.
                 else:
                     tick = event.xdata
                 self.ParentWindow.ChangeRange(int(-event.step) / 3, tick)
+                self.ParentWindow.VetoScrollEvent = True
         
         def OnDragging(self, x, y):
             width, height = self.GetSize()
@@ -1455,6 +1457,7 @@
             self.DraggingAxesPanel = None
             self.DraggingAxesBoundingBox = None
             self.DraggingAxesMousePos = None
+            self.VetoScrollEvent = False
             self.VariableNameMask = []
             
             self.GraphicPanels = []
@@ -1513,6 +1516,8 @@
             self.GraphicsWindow.Bind(wx.EVT_ERASE_BACKGROUND, self.OnGraphicsWindowEraseBackground)
             self.GraphicsWindow.Bind(wx.EVT_PAINT, self.OnGraphicsWindowPaint)
             self.GraphicsWindow.Bind(wx.EVT_SIZE, self.OnGraphicsWindowResize)
+            self.GraphicsWindow.Bind(wx.EVT_MOUSEWHEEL, self.OnGraphicsWindowMouseWheel)
+            
             main_sizer.AddWindow(self.GraphicsWindow, 1, flag=wx.GROW)
             
             self.GraphicsSizer = wx.BoxSizer(wx.VERTICAL)
@@ -2239,4 +2244,9 @@
     def OnGraphicsWindowResize(self, event):
         self.RefreshGraphicsWindowScrollbars()
         event.Skip()
-    
\ No newline at end of file
+
+    def OnGraphicsWindowMouseWheel(self, event):
+        if self.VetoScrollEvent:
+            self.VetoScrollEvent = False
+        else:
+            event.Skip()