# HG changeset patch # User Laurent Bessard # Date 1369412942 -7200 # Node ID 9cc1a3fa96199cbe830f7cbc909cbd1f78425de6 # Parent ad09b4a755ce4dfb1ff27b556923d19066eeed33 Add support for moving cursor in Debug Graphs using arrow keys diff -r ad09b4a755ce -r 9cc1a3fa9619 controls/DebugVariablePanel.py --- a/controls/DebugVariablePanel.py Fri May 24 16:29:57 2013 +0200 +++ b/controls/DebugVariablePanel.py Fri May 24 18:29:02 2013 +0200 @@ -812,6 +812,7 @@ FigureCanvas.__init__(self, parent, -1, self.Figure) self.SetBackgroundColour(wx.WHITE) + self.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown) self.Bind(wx.EVT_ENTER_WINDOW, self.OnEnter) self.Bind(wx.EVT_LEAVE_WINDOW, self.OnLeave) self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground) @@ -1160,6 +1161,18 @@ self.ParentWindow.ForceRefresh() DebugVariableViewer.OnLeave(self, event) + KEY_CURSOR_INCREMENT = { + wx.WXK_LEFT: -1, + wx.WXK_RIGHT: 1, + wx.WXK_UP: -10, + wx.WXK_DOWN: 10} + def OnKeyDown(self, event): + if self.CursorTick is not None: + self.ParentWindow.MoveCursorTick( + self.KEY_CURSOR_INCREMENT.get( + event.GetKeyCode(), 0)) + event.Skip() + def HandleCursorMove(self, event): start_tick, end_tick = self.ParentWindow.GetRange() cursor_tick = None @@ -1621,6 +1634,20 @@ self.Fixed = True self.UpdateCursorTick() + def MoveCursorTick(self, move): + if self.CursorTick is not None: + cursor_tick = max(self.Ticks[0], + min(self.CursorTick + move, + self.Ticks[-1])) + self.CursorTick = self.Ticks[ + numpy.argmin(numpy.abs(self.Ticks - cursor_tick))] + self.StartTick = max(self.Ticks[ + numpy.argmin(numpy.abs(self.Ticks - + self.CursorTick + self.CurrentRange))], + min(self.StartTick, self.CursorTick)) + self.RefreshCanvasPosition() + self.UpdateCursorTick() + def ResetCursorTick(self): self.CursorTick = None self.UpdateCursorTick()