editors/ConfTreeNodeEditor.py
changeset 1180 276a30c68eaa
parent 1179 3e7bd88fcff7
child 1281 47131e3388f4
--- a/editors/ConfTreeNodeEditor.py	Tue May 28 17:52:07 2013 +0200
+++ b/editors/ConfTreeNodeEditor.py	Tue May 28 17:52:57 2013 +0200
@@ -210,11 +210,8 @@
                 panel_style |= wx.SUNKEN_BORDER
             self.ParamsEditor = wx.ScrolledWindow(parent, 
                   style=panel_style)
-            self.ParamsEditor.Bind(wx.EVT_SIZE, self.OnWindowResize)
-            self.ParamsEditor.Bind(wx.EVT_MOUSEWHEEL, self.OnMouseWheel)
-            
-            # Variable allowing disabling of ParamsEditor scroll when Popup shown 
-            self.ScrollingEnabled = True
+            self.ParamsEditor.Bind(wx.EVT_SIZE, self.OnParamsEditorResize)
+            self.ParamsEditor.Bind(wx.EVT_SCROLLWIN, self.OnParamsEditorScroll)
             
             self.ParamsEditorSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=1, vgap=5)
             self.ParamsEditorSizer.AddGrowableCol(0)
@@ -278,9 +275,6 @@
             self.RefreshConfNodeParamsSizer()
             self.RefreshScrollbars()
     
-    def EnableScrolling(self, enable):
-        self.ScrollingEnabled = enable
-    
     def RefreshIECChannelControlsState(self):
         self.FullIECChannel.SetLabel(self.Controler.GetFullIEC_Channel())
         self.IECCDownButton.Enable(self.Controler.BaseParams.getIEC_Channel() > 0)
@@ -469,7 +463,6 @@
                         choices = self.ParentWindow.GetConfigEntry(element_path, [""])
                         textctrl = TextCtrlAutoComplete(name=element_infos["name"], 
                                                         parent=self.ParamsEditor, 
-                                                        appframe=self, 
                                                         choices=choices, 
                                                         element_path=element_path,
                                                         size=wx.Size(300, -1))
@@ -477,7 +470,9 @@
                         boxsizer.AddWindow(textctrl)
                         if element_infos["value"] is not None:
                             textctrl.ChangeValue(str(element_infos["value"]))
-                        textctrl.Bind(wx.EVT_TEXT, self.GetTextCtrlCallBackFunction(textctrl, element_path))
+                        callback = self.GetTextCtrlCallBackFunction(textctrl, element_path)
+                        textctrl.Bind(wx.EVT_TEXT_ENTER, callback)
+                        textctrl.Bind(wx.EVT_KILL_FOCUS, callback)
             first = False
     
     
@@ -569,11 +564,14 @@
         self.ParamsEditor.SetScrollbars(SCROLLBAR_UNIT, SCROLLBAR_UNIT, 
                 maxx / SCROLLBAR_UNIT, maxy / SCROLLBAR_UNIT, posx, posy)
     
-    def OnWindowResize(self, event):
+    def OnParamsEditorResize(self, event):
         self.RefreshScrollbars()
         event.Skip()
     
-    def OnMouseWheel(self, event):
-        if self.ScrollingEnabled:
-            event.Skip()
-    
+    def OnParamsEditorScroll(self, event):
+        control = self.ParamsEditor.FindFocus()
+        if isinstance(control, TextCtrlAutoComplete):
+            control.DismissListBox()
+            self.Refresh()
+        event.Skip()
+