Split IDE's frame OnCloseFrame() into TryCloseFrame() and OnCloseFrame(), to help further customization
authorEdouard Tisserant
Fri, 25 Jan 2019 14:06:11 +0100
changeset 2483 6a7f92b84855
parent 2482 cb53d3bf3380
child 2484 2318a7cde101
Split IDE's frame OnCloseFrame() into TryCloseFrame() and OnCloseFrame(), to help further customization
BeremizIDE.py
--- a/BeremizIDE.py	Wed Jan 09 14:10:07 2019 +0100
+++ b/BeremizIDE.py	Fri Jan 25 14:06:11 2019 +0100
@@ -615,11 +615,7 @@
     def AddToDoBeforeQuit(self, Thing):
         self.ToDoBeforeQuit.append(Thing)
 
-    def OnCloseFrame(self, event):
-        for evt_type in [wx.EVT_SET_FOCUS,
-                         wx.EVT_KILL_FOCUS,
-                         wx.stc.EVT_STC_UPDATEUI]:
-            self.LogConsole.Unbind(evt_type)
+    def TryCloseFrame(self):
         if self.CTR is None or self.CheckSaveBeforeClosing(_("Close Application")):
             if self.CTR is not None:
                 self.CTR.KillDebugThread()
@@ -631,8 +627,14 @@
                 Thing()
             self.ToDoBeforeQuit = []
 
+            return True
+        return False
+
+    def OnCloseFrame(self, event):
+        if self.TryCloseFrame():
             event.Skip()
         else:
+            # prevent event to continue, i.e. cancel closing
             event.Veto()
 
     def RefreshFileMenu(self):