dabo Commit
Revision 5569
Date: 2009-12-28 08:11:46 -0800 (Mon, 28 Dec 2009)
Author: Ed
Trac: http://trac.dabodev.com/changeset/5569

Changed:
U   trunk/dabo/ui/uiwx/dComboBox.py

Log:
Corrected the issues raised by Jacek Ka?\197?\130ucki regarding the navigation 
problems of dComboBox under Windows. 


Diff:
Modified: trunk/dabo/ui/uiwx/dComboBox.py
===================================================================
--- trunk/dabo/ui/uiwx/dComboBox.py     2009-12-27 20:25:03 UTC (rev 5568)
+++ trunk/dabo/ui/uiwx/dComboBox.py     2009-12-28 16:11:46 UTC (rev 5569)
@@ -40,7 +40,8 @@
        def _initEvents(self):
                super(dComboBox, self)._initEvents()
                self.Bind(wx.EVT_COMBOBOX, self.__onComboBox)
-               self.Bind(wx.EVT_TEXT_ENTER, self.__onTextBox)
+#              self.Bind(wx.EVT_TEXT_ENTER, self.__onTextBox)
+               self.Bind(wx.EVT_KEY_DOWN, self.__onWxKeyDown)
                        
        
        def __onComboBox(self, evt):
@@ -49,18 +50,35 @@
                self._onWxHit(evt)
                
                
-       def __onTextBox(self, evt):
-               self._userVal = True
-               evt.Skip()
-               if self.AppendOnEnter:
-                       txt = evt.GetString()
-                       if txt not in self.Choices:
-                               self._textToAppend = txt
-                               if self.beforeAppendOnEnter() is not False:
-                                       if self._textToAppend:
-                                               
self.appendItem(self._textToAppend, select=True)
-                                               self.afterAppendOnEnter()
-               self.raiseEvent(dabo.dEvents.Hit, evt)
+       def __onWxKeyDown(self, evt):
+               """We need to capture the Enter/Return key in order to implement
+               the AppendOnEnter behavior. However, under Windows this leads 
to 
+               navigation issues, so we also need to capture when Tab is 
pressed, 
+               and handle the navigation ourselves.
+               """
+               # Shorthand for easy reference
+               dk = dabo.ui.dKeys
+               # Don't call the native Skip() if Tab is pressed; we'll handle 
it ourselves.
+               callSkip = True
+               enter_codes = (dk.key_Return, dk.key_Numpad_enter)
+               keyCode = evt.GetKeyCode()
+               if keyCode in enter_codes:
+                       self._userVal = True
+                       if self.AppendOnEnter:
+                               txt = self.GetValue()
+                               if txt not in self.Choices:
+                                       self._textToAppend = txt
+                                       if self.beforeAppendOnEnter() is not 
False:
+                                               if self._textToAppend:
+                                                       
self.appendItem(self._textToAppend, select=True)
+                                                       
self.afterAppendOnEnter()
+                       self.raiseEvent(dabo.dEvents.Hit, evt)
+               elif keyCode == dk.key_Tab:
+                       forward = not evt.ShiftDown()
+                       self.Navigate(forward)
+                       callSkip = False
+               if callSkip:
+                       evt.Skip()
        
 
        def __onKeyChar(self, evt):



_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev
Searchable Archives: http://leafe.com/archives/search/dabo-dev
This message: 
http://leafe.com/archives/byMID/[email protected]

Reply via email to