From ea200f23ddcc5e07d0cc8115a19521de9036d17c Mon Sep 17 00:00:00 2001 From: Romain Date: Tue, 19 Nov 2024 12:38:18 +0100 Subject: [PATCH] feat: close the dialog when pressing the ESC key (#180) --- plugins/plugin.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/plugins/plugin.py b/plugins/plugin.py index 911a8ff..91b9bb8 100644 --- a/plugins/plugin.py +++ b/plugins/plugin.py @@ -84,6 +84,16 @@ class KiCadToJLCForm(wx.Frame): self.Centre(wx.BOTH) + # Bind the ESC key event to a handler + self.Bind(wx.EVT_CHAR_HOOK, self.onKey) + + # Close the dialog when pressing the ESC key + def onKey(self, event): + if event.GetKeyCode() == wx.WXK_ESCAPE: + self.Close(True) + else: + event.Skip() + def onGenerateButtonClick(self, event): options = dict()