now dialogs Find and Search in Project can be closed with ESC button
authorSergey Surkov <surkovsv93@gmail.com>
Fri, 28 Oct 2016 18:28:10 +0300
changeset 1558 d75cc9ad328e
parent 1557 52a78c90870f
child 1559 91129212e9a6
now dialogs Find and Search in Project can be closed with ESC button
dialogs/FindInPouDialog.py
dialogs/SearchInProjectDialog.py
--- a/dialogs/FindInPouDialog.py	Fri Oct 28 18:17:35 2016 +0300
+++ b/dialogs/FindInPouDialog.py	Fri Oct 28 18:28:10 2016 +0300
@@ -61,6 +61,7 @@
         
         self.FindPattern = wx.TextCtrl(panel)
         self.Bind(wx.EVT_TEXT, self.OnFindPatternChanged, self.FindPattern)
+        self.Bind(wx.EVT_CHAR_HOOK, self.OnEscapeKey)
         patterns_sizer.AddWindow(self.FindPattern, flag=wx.GROW)
         
         params_sizer = wx.BoxSizer(wx.HORIZONTAL)
@@ -135,6 +136,13 @@
         self.Hide()
         event.Skip()
 
+    def OnEscapeKey(self, event):
+        keycode = event.GetKeyCode()
+        if keycode == wx.WXK_ESCAPE:
+            self.OnCloseButton(event)
+        else:
+            event.Skip()
+
     def OnFindPatternChanged(self, event):
         self.RefreshButtonsState()
         event.Skip()
--- a/dialogs/SearchInProjectDialog.py	Fri Oct 28 18:17:35 2016 +0300
+++ b/dialogs/SearchInProjectDialog.py	Fri Oct 28 18:28:10 2016 +0300
@@ -62,7 +62,7 @@
         self.Pattern = wx.TextCtrl(self)
         self.Bind(wx.EVT_TEXT, self.FindPatternChanged, self.Pattern)
         pattern_sizer.AddWindow(self.Pattern, flag=wx.GROW)
-        
+        self.Bind(wx.EVT_CHAR_HOOK, self.OnEscapeKey)
         self.RegularExpression = wx.CheckBox(self, label=_('Regular expression'))
         pattern_sizer.AddWindow(self.RegularExpression, flag=wx.GROW)
         
@@ -125,12 +125,20 @@
     def FindPatternChanged(self, event):
         self.RefreshButtonsState()
         event.Skip()
+
     def OnScopeChanged(self, event):
         self.ElementsList.Enable(self.OnlyElements.GetValue())
         event.Skip()
 
     def OnCloseButton(self, event):
         self.EndModal(wx.ID_CANCEL)
+
+    def OnEscapeKey(self, event):
+        keycode = event.GetKeyCode()
+        if keycode == wx.WXK_ESCAPE:
+            self.OnCloseButton(event)
+        else:
+            event.Skip()
     
     def OnFindButton(self, event):
         message = None