[GRASS-SVN] r39913 - grass/branches/develbranch_6/gui/wxpython/gui_modules

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Dec 6 05:25:53 EST 2009


Author: martinl
Date: 2009-12-06 05:25:53 -0500 (Sun, 06 Dec 2009)
New Revision: 39913

Modified:
   grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp_window.py
   grass/branches/develbranch_6/gui/wxpython/gui_modules/toolbars.py
Log:
wxGUI/vdigit: initial hot-keys (p/l) see #497
	      (merge r39911 & r39912 from trunk)


Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp_window.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp_window.py	2009-12-06 10:22:47 UTC (rev 39912)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/mapdisp_window.py	2009-12-06 10:25:53 UTC (rev 39913)
@@ -87,6 +87,9 @@
     def OnLeftUp(self, event):
         pass
 
+    def OnKeyDown(self, event):
+        pass
+    
     def OnMouseMotion(self, event):
         pass
 
@@ -233,7 +236,8 @@
         self._buffer = ''
 
         self.Bind(wx.EVT_ERASE_BACKGROUND, lambda x:None)
-
+        self.Bind(wx.EVT_KEY_DOWN , self.OnKeyDown)
+        
         # vars for handling mouse clicks
         self.dragid   = -1
         self.lastpos  = (0, 0)
@@ -446,6 +450,25 @@
         
         return coords, boxw, boxh
 
+    def OnKeyDown(self, event):
+        """!Key pressed"""
+        shift = event.ShiftDown()
+        kc = event.GetKeyCode()
+        vdigitToolbar = self.parent.toolbars['vdigit']
+        ### vdigit
+        if vdigitToolbar:
+            event = None
+            if not shift:
+                if kc == ord('P'):
+                    event = wx.CommandEvent(winid = vdigitToolbar.addPoint)
+                    tool = vdigitToolbar.OnAddPoint
+                elif kc == ord('L'):
+                    event = wx.CommandEvent(winid = vdigitToolbar.addLine)
+                    tool = vdigitToolbar.OnAddLine
+            if event:
+                vdigitToolbar.OnTool(event)
+                tool(event)
+        
     def OnPaint(self, event):
         """!
         Draw PseudoDC's to buffered paint DC

Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/toolbars.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/toolbars.py	2009-12-06 10:22:47 UTC (rev 39912)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/toolbars.py	2009-12-06 10:25:53 UTC (rev 39913)
@@ -270,7 +270,8 @@
         elif tool == 2 and not self.mapdisplay.toolbars['vdigit']:
             self.ExitToolbars()
             self.mapdisplay.AddToolbar("vdigit")
-
+            self.mapdisplay.MapWindow.SetFocus()
+        
     def ExitToolbars(self):
         if self.mapdisplay.toolbars['vdigit']:
             self.mapdisplay.toolbars['vdigit'].OnExit()
@@ -613,9 +614,8 @@
             
             self.action['id'] = event.GetId()
             event.Skip()
-        else:
-            # initialize toolbar
-            self.toolbar[0].ToggleTool(self.action['id'], True)
+        
+        self.toolbar[0].ToggleTool(self.action['id'], True)
 
         # clear tmp canvas
         if self.action['id'] != id:
@@ -625,6 +625,9 @@
                 # cancel action
                 self.parent.MapWindow.OnMiddleDown(None)
         
+        # set focus
+        self.parent.MapWindow.SetFocus()
+        
     def OnAddPoint(self, event):
         """!Add point to the vector map Laier"""
         Debug.msg (2, "VDigitToolbar.OnAddPoint()")



More information about the grass-commit mailing list