[GRASS-SVN] r39911 - grass/trunk/gui/wxpython/gui_modules

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Dec 6 05:11:31 EST 2009


Author: martinl
Date: 2009-12-06 05:11:30 -0500 (Sun, 06 Dec 2009)
New Revision: 39911

Modified:
   grass/trunk/gui/wxpython/gui_modules/mapdisp_window.py
   grass/trunk/gui/wxpython/gui_modules/toolbars.py
Log:
wxGUI/vdigit: initial hot-keys (p/l) see #497


Modified: grass/trunk/gui/wxpython/gui_modules/mapdisp_window.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/mapdisp_window.py	2009-12-06 08:47:10 UTC (rev 39910)
+++ grass/trunk/gui/wxpython/gui_modules/mapdisp_window.py	2009-12-06 10:11:30 UTC (rev 39911)
@@ -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:
+            if not shift:
+                event = None
+                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/trunk/gui/wxpython/gui_modules/toolbars.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/toolbars.py	2009-12-06 08:47:10 UTC (rev 39910)
+++ grass/trunk/gui/wxpython/gui_modules/toolbars.py	2009-12-06 10:11:30 UTC (rev 39911)
@@ -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:



More information about the grass-commit mailing list