From 4ae6162b27f2a8cb5f3665d37a7fb59bbc14f2cc Mon Sep 17 00:00:00 2001 From: William Hall Date: Fri, 8 Sep 2017 20:36:40 -0400 Subject: [PATCH] Enable Esc key and fix issue 400 Enable use of Esc key to navigate back through menus by letting unhandled keys in gcodeCanvas.py be passed to the next callback. Now the Esc key causes Ground Control to crash, per issue 400, when pressed at the main screen or in the settings menu. The issue is caused by the close_settings() handler in main.py. Since it doesn't do anything besides call the super version of itself, deleting it solves the problem. --- UIElements/gcodeCanvas.py | 5 ++++- main.py | 8 +------- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/UIElements/gcodeCanvas.py b/UIElements/gcodeCanvas.py index 640af952..9b61ebce 100644 --- a/UIElements/gcodeCanvas.py +++ b/UIElements/gcodeCanvas.py @@ -85,10 +85,13 @@ def _on_keyboard_down(self, keyboard, keycode, text, modifiers): if keycode[1] == self.data.config.get('Ground Control Settings', 'zoomIn'): mat = Matrix().scale(1-scaleFactor, 1-scaleFactor, 1) self.scatterInstance.apply_transform(mat, anchor) + return True # we handled this key - don't pass to other callbacks elif keycode[1] == self.data.config.get('Ground Control Settings', 'zoomOut'): mat = Matrix().scale(1+scaleFactor, 1+scaleFactor, 1) self.scatterInstance.apply_transform(mat, anchor) - return True + return True # we handled this key - don't pass to other callbacks + else: + return False # we didn't handle this key - let next callback handle it def isClose(self, a, b): return abs(a-b) <= self.data.tolerance diff --git a/main.py b/main.py index 3b011a31..5e64feab 100755 --- a/main.py +++ b/main.py @@ -5,6 +5,7 @@ ''' from kivy.config import Config Config.set('input', 'mouse', 'mouse,disable_multitouch') +Config.set('kivy', 'exit_on_escape', '0') from kivy.app import App from kivy.uix.gridlayout import GridLayout from kivy.uix.floatlayout import FloatLayout @@ -426,13 +427,6 @@ def on_config_change(self, config, section, key, value): if (key == "truncate") or (key == "digits"): self.frontpage.gcodecanvas.reloadGcode() - - - def close_settings(self, settings): - """ - Close settings panel - """ - super(GroundControlApp, self).close_settings(settings) def push_settings_to_machine(self, *args):