瀏覽代碼

implement menu shortcuts (see trac https://trac.osgeo.org/grass/ticket/725)

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@39019 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 15 年之前
父節點
當前提交
46f32daac4
共有 3 個文件被更改,包括 12 次插入3 次删除
  1. 6 1
      gui/wxpython/gui_modules/menudata.py
  2. 5 2
      gui/wxpython/wxgui.py
  3. 1 0
      gui/wxpython/xml/menudata.xml

+ 6 - 1
gui/wxpython/gui_modules/menudata.py

@@ -41,6 +41,7 @@ class Data:
 	    handler  = mi.find('handler').text
 	    gcmd     = mi.find('command')  # optional
             keywords = mi.find('keywords') # optional
+            shortcut = mi.find('shortcut') # optional
 	    if gcmd != None:
 		gcmd = gcmd.text
 	    else:
@@ -49,7 +50,11 @@ class Data:
                 keywords = keywords.text
             else:
                 keywords = ""
-	    return (label, help, handler, gcmd, keywords)
+            if shortcut != None:
+                shortcut = shortcut.text
+            else:
+                shortcut = ""
+	    return (label, help, handler, gcmd, keywords, shortcut)
 	elif mi.tag == 'menu':
 	    return self.getMenu(mi)
 	else:

+ 5 - 2
gui/wxpython/wxgui.py

@@ -231,7 +231,7 @@ class GMFrame(wx.Frame):
         self.Bind(wx.EVT_MENU_HIGHLIGHT_ALL, self.OnMenuHighlight)
         return menu
 
-    def __createMenuItem(self, menu, label, help, handler, gcmd, keywords, kind = wx.ITEM_NORMAL):
+    def __createMenuItem(self, menu, label, help, handler, gcmd, keywords, shortcut = '', kind = wx.ITEM_NORMAL):
         """!Creates menu items"""
 
         if not label:
@@ -242,7 +242,10 @@ class GMFrame(wx.Frame):
             helpString = gcmd + ' -- ' + help
         else:
             helpString = help
-
+        
+        if shortcut:
+            label += '\t' + shortcut
+        
         menuItem = menu.Append(wx.ID_ANY, label, helpString, kind)
         
         self.menucmd[menuItem.GetId()] = gcmd

+ 1 - 0
gui/wxpython/xml/menudata.xml

@@ -643,6 +643,7 @@
 	  <label>E&amp;xit</label>
 	  <help>Exit GUI</help>
 	  <handler>self.OnCloseWindow</handler>
+	  <shortcut>Ctrl+Q</shortcut>
 	</menuitem>
       </items>
     </menu>