Add support for leaving LocationControl when RETURN or TAB pressed
authorlaurent
Thu, 08 Oct 2009 16:40:08 +0200
changeset 443 5f7d5d1a6f99
parent 442 a756b58699b8
child 444 865a33108ea0
Add support for leaving LocationControl when RETURN or TAB pressed
VariablePanel.py
--- a/VariablePanel.py	Thu Oct 08 16:39:08 2009 +0200
+++ b/VariablePanel.py	Thu Oct 08 16:40:08 2009 +0200
@@ -880,7 +880,8 @@
         
         # create location text control
         self.Location = wx.TextCtrl(id=-1, name='Location', parent=self,
-              pos=wx.Point(0, 0), size=wx.Size(0, 0), style=0)
+              pos=wx.Point(0, 0), size=wx.Size(0, 0), style=wx.TE_PROCESS_ENTER)
+        self.Location.Bind(wx.EVT_KEY_DOWN, self.OnLocationChar)
         
         # create browse button
         self.BrowseButton = wx.Button(id=-1, label='...', 
@@ -926,6 +927,14 @@
 
         self.Location.SetFocus()
 
+    def OnLocationChar(self, event):
+        keycode = event.GetKeyCode()
+        if keycode == wx.WXK_RETURN or keycode == wx.WXK_TAB:
+            self.Parent.Parent.ProcessEvent(event)
+            self.Parent.Parent.SetFocus()
+        else:
+            event.Skip()
+
     def SetInsertionPoint(self, i):
         self.Location.SetInsertionPoint(i)
     
@@ -940,7 +949,10 @@
         wx.grid.PyGridCellEditor.__init__(self)
         self.Table = table
         self.Controler = controler
-        
+
+    def __del__(self):
+        self.CellControl = None
+    
     def Create(self, parent, id, evt_handler):
         locations = self.Controler.GetVariableLocationTree()
         if len(locations) > 0: