Switch pane focus

Technical questions about Editra, post them here

Re: Switch pane focus

Postby cody » Thu Dec 18, 2008 5:32 pm

Also just looked at the hint code of the AuiMgr and it looks like a really easy solution actually the code below basically does it

Code: Select all
pane = self._mgr.GetPane(paneName)
pane.ShowHint(c.window.GetRect())
# m.HideHint()
User avatar
cody
Site Admin
 
Posts: 1307
Joined: Mon Oct 09, 2006 2:49 am
Location: United States

Re: Switch pane focus

Postby cody » Thu Dec 18, 2008 8:59 pm

I went ahead and implemented this since it was so easy. It looks pretty nice too.

Also temporarily set the default keybinding to Alt+1 on windows/linux. Will still need to add the methods to set the keybinding in the navigator window.


cody
User avatar
cody
Site Admin
 
Posts: 1307
Joined: Mon Oct 09, 2006 2:49 am
Location: United States

Re: Switch pane focus

Postby cowo » Fri Dec 19, 2008 10:22 am

cody wrote:I went ahead and implemented this since it was so easy. It looks pretty nice too.

Also temporarily set the default keybinding to Alt+1 on windows/linux. Will still need to add the methods to set the keybinding in the navigator window.


Yeah, works OK!

Here's a small patch for the keybinding issue. Isn't there a way to convert an accelerator string specification into a list of [WXK_modifiers, WXK_somekey]?

Ahem... "The extension patch|diff is not allowed". Maybe there's something wrong on my side?

Code: Select all
Index: src/eclib/auinavi.py
===================================================================
--- src/eclib/auinavi.py   (revision 57430)
+++ src/eclib/auinavi.py   (working copy)
@@ -31,20 +31,37 @@
 
 class AuiPaneNavigator(wx.Dialog):
     """Navigate through Aui Panes"""
-    def __init__(self, parent, auiMgr, icon=None, title=''):
+    def __init__(self, parent, auiMgr, icon=None, title='', accel=None):
         """@param auiMgr: Main window Aui Manager"""
         wx.Dialog.__init__(self, parent, wx.ID_ANY, "", style=wx.STAY_ON_TOP)
 
         # Attributes
         self._auimgr = auiMgr
         self._selectedItem = -1
         self._indexMap = list()
         self._sel = 0
         self._tabed = 0
-        self._close_keys = [wx.WXK_ALT, wx.WXK_CONTROL, wx.WXK_RETURN]
-        self._navi_keys = [wx.WXK_TAB, ord('1')] # <- TEMP
-
+        self._close_keys = [wx.WXK_RETURN, wx.WXK_ESCAPE]
+        self._navi_keys = [wx.WXK_TAB]
+       
         # Setup
+        if (accel):
+            accel = accel.replace('-', '+')
+            #TODO: isn't there a reasonable way to convert an accelerator string
+            #into a list of WXK_* ?
+            allModifiers = {
+                "ALT": wx.WXK_ALT,
+                "CTRL": wx.WXK_CONTROL,
+                "SHIFT": wx.WXK_SHIFT
+            }
+            parts = accel.strip().split('+')
+            modifiers = [allModifiers[k.upper()] for k in parts[0:-1]]
+            #TODO: could as well be a F1 or something not convertible
+            keycode = ord(parts[-1])
+            self._close_keys += modifiers
+            self._navi_keys += [keycode]
+       
         sz = wx.BoxSizer(wx.VERTICAL)
         self._listBox = wx.ListBox(self, wx.ID_ANY, wx.DefaultPosition,
                                    wx.Size(200, 150), list(),
@@ -108,8 +125,6 @@
             event.Skip()
         elif key_code in self._close_keys:
             self.CloseDialog()
-        elif key_code == wx.WXK_ESCAPE:
-            self.CloseDialog()
         else:
             event.Skip()
 
Index: src/ed_main.py
===================================================================
--- src/ed_main.py   (revision 57430)
+++ src/ed_main.py   (working copy)
@@ -1009,10 +1009,12 @@
         if evt.GetId() == ID_PANELIST:
             if self._paneNavi is not None:
                 return
-
+           
+            accelKey = ed_menu.EdMenuBar.keybinder.GetBinding(ID_PANELIST)
             bmp = wx.ArtProvider.GetBitmap(str(ID_NEW_WINDOW), wx.ART_MENU)
-            self._paneNavi = auinavi.AuiPaneNavigator(self, self._mgr, bmp,
-                                                      _("Aui Pane Navigator"))
+            self._paneNavi = auinavi.AuiPaneNavigator(
+                self, self._mgr, bmp, _("Aui Pane Navigator"), accelKey
+            )
             self._paneNavi.SetReturnCode(wx.ID_OK)
             self._paneNavi.ShowModal()
Giuseppe "Cowo" Corbelli
cowo
User
 
Posts: 12
Joined: Fri Dec 12, 2008 11:28 am

Re: Switch pane focus

Postby cody » Sat Dec 20, 2008 4:32 pm

Thanks,

Will look at adding this soon. Need to do another emergency release to correct an issue that happened in the last build.

I tried to fix the attachment issue again. Hopefully should work from now.


Cody
User avatar
cody
Site Admin
 
Posts: 1307
Joined: Mon Oct 09, 2006 2:49 am
Location: United States

Re: Switch pane focus

Postby cody » Mon Dec 29, 2008 4:58 am

Added shortcut for Toggle Fold today. There are some issues with the fold all code that I will need to look over again before adding.

Thanks,

Cody
User avatar
cody
Site Admin
 
Posts: 1307
Joined: Mon Oct 09, 2006 2:49 am
Location: United States

Previous

Return to Technical Discussion

Who is online

Users browsing this forum: No registered users and 1 guest

cron