Add hotkey (F12) for switching perspective.
authorSergey Surkov <surkovsv93@gmail.com>
Mon, 12 Sep 2016 16:41:21 +0300
changeset 1530 24d8e8c233bd
parent 1522 fef49488b5c7
child 1531 d2b3bbbb1028
Add hotkey (F12) for switching perspective.

Switching perspective feature hides/restores all panels except of the main editor window for current FB.
So all available screen space is used for editor.
Beremiz.py
IDEFrame.py
--- a/Beremiz.py	Fri Sep 09 13:33:49 2016 +0300
+++ b/Beremiz.py	Mon Sep 12 16:41:21 2016 +0300
@@ -393,6 +393,11 @@
         inspectorID = wx.NewId()
         self.Bind(wx.EVT_MENU, self.OnOpenWidgetInspector, id=inspectorID)
         accels = [wx.AcceleratorEntry(wx.ACCEL_CTRL|wx.ACCEL_ALT, ord('I'), inspectorID)]
+
+        keyID = wx.NewId()
+        self.Bind(wx.EVT_MENU, self.SwitchFullScrMode, id=keyID)
+        accels += [wx.AcceleratorEntry(wx.ACCEL_NORMAL, wx.WXK_F12, keyID)]
+
         for method,shortcut in [("Stop",     wx.WXK_F4),
                                 ("Run",      wx.WXK_F5),
                                 ("Transfer", wx.WXK_F6),
--- a/IDEFrame.py	Fri Sep 09 13:33:49 2016 +0300
+++ b/IDEFrame.py	Mon Sep 12 16:41:21 2016 +0300
@@ -64,7 +64,8 @@
 
 # Define PLCOpenEditor DisplayMenu extra items id
 [ID_PLCOPENEDITORDISPLAYMENURESETPERSPECTIVE,
-] = [wx.NewId() for _init_coll_DisplayMenu_Items in range(1)]
+ ID_PLCOPENEDITORDISPLAYMENUSWITCHPERSPECTIVE,
+] = [wx.NewId() for _init_coll_DisplayMenu_Items in range(2)]
 
 #-------------------------------------------------------------------------------
 #                            EditorToolBar definitions
@@ -442,6 +443,10 @@
             self.Bind(wx.EVT_MENU, self.GenerateZoomFunction(idx), id=new_id)
 
         parent.AppendSeparator()
+        AppendMenu(parent, help='', id=ID_PLCOPENEDITORDISPLAYMENUSWITCHPERSPECTIVE,
+                   kind=wx.ITEM_NORMAL, text=_(u'Switch perspective') + '\tF12')
+        self.Bind(wx.EVT_MENU, self.SwitchFullScrMode, id=ID_PLCOPENEDITORDISPLAYMENUSWITCHPERSPECTIVE)
+
         AppendMenu(parent, help='', id=ID_PLCOPENEDITORDISPLAYMENURESETPERSPECTIVE,
               kind=wx.ITEM_NORMAL, text=_(u'Reset Perspective'))
         self.Bind(wx.EVT_MENU, self.OnResetPerspective, id=ID_PLCOPENEDITORDISPLAYMENURESETPERSPECTIVE)
@@ -1438,15 +1443,18 @@
         def OnTabsOpenedDClick(event):
             pos = event.GetPosition()
             if tabctrl.TabHitTest(pos.x, pos.y, None):
-                pane = self.AUIManager.GetPane(self.TabsOpened)
-                if pane.IsMaximized():
-                    self.AUIManager.RestorePane(pane)
-                else:
-                    self.AUIManager.MaximizePane(pane)
-                self.AUIManager.Update()
+                self.SwitchFullScrMode(event)
             event.Skip()
         return OnTabsOpenedDClick
 
+    def SwitchFullScrMode(self,evt):
+        pane = self.AUIManager.GetPane(self.TabsOpened)
+        if pane.IsMaximized():
+            self.AUIManager.RestorePane(pane)
+        else:
+            self.AUIManager.MaximizePane(pane)
+        self.AUIManager.Update()
+
 #-------------------------------------------------------------------------------
 #                         Types Tree Management Functions
 #-------------------------------------------------------------------------------