From 0d2525d60e921887c0812d7a9eb84636b377d070 Mon Sep 17 00:00:00 2001 From: Ferdi van der Werf Date: Fri, 11 May 2012 04:01:39 +0200 Subject: [PATCH] Fixes #91 Fixed some keyboard shortcuts for mac: command + keys and control + a or e If more shortcuts are required, post them in issue #91. --- Cura/gui/gcodeTextArea.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/Cura/gui/gcodeTextArea.py b/Cura/gui/gcodeTextArea.py index b8fc86f4..aa2701d5 100644 --- a/Cura/gui/gcodeTextArea.py +++ b/Cura/gui/gcodeTextArea.py @@ -29,12 +29,45 @@ else: self.IndicatorSetForeground(1, "#FF0000") self.SetWrapMode(wx.stc.STC_WRAP_NONE) self.SetScrollWidth(1000) + if sys.platform == 'darwin': + self.Bind(wx.EVT_KEY_DOWN, self.OnMacKeyDown) #GCodes and MCodes as supported by Marlin #GCode 21 is not really supported by Marlin, but we still do not report it as error as it's often used. self.supportedGCodes = [0,1,2,3,4,21,28,90,91,92] self.supportedMCodes = [17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,42,80,81,82,83,84,85,92,104,105,106,107,109,114,115,117,119,140,190,201,202,203,204,205,206,220,221,240,301,302,303,400,500,501,502,503,999] + def OnMacKeyDown(self, e): + code = e.GetKeyCode(); + stopPropagation = True + #Command + if e.CmdDown(): + if code == wx._core.WXK_LEFT: + self.GotoLine(self.GetCurrentLine()) + elif code == wx._core.WXK_RIGHT: + self.GotoPos(self.GetLineEndPosition(self.GetCurrentLine())) + elif code == wx._core.WXK_UP: + self.GotoPos(0) + elif code == wx._core.WXK_DOWN: + self.GotoPos(self.GetLength()) + else: + stopPropagation = False + # Control + elif e.GetModifiers() & 0xF0: + if code == 65: # A + self.GotoLine(self.GetCurrentLine()) + elif code == 69: # E + self.GotoPos(self.GetLineEndPosition(self.GetCurrentLine())) + else: + stopPropagation = False + else: + stopPropagation = False + # Event propagation + if stopPropagation: + e.StopPropagation() + else: + e.Skip() + def OnStyle(self, e): lineNr = self.LineFromPosition(self.GetEndStyled()) while self.PositionFromLine(lineNr) > -1: -- 2.30.2