commit-gnue
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnue] r8606 - in branches/forms-0.5/src: . uidrivers/wx26/widgets


From: johannes
Subject: [gnue] r8606 - in branches/forms-0.5/src: . uidrivers/wx26/widgets
Date: Wed, 23 Aug 2006 04:19:34 -0500 (CDT)

Author: johannes
Date: 2006-08-23 04:19:33 -0500 (Wed, 23 Aug 2006)
New Revision: 8606

Modified:
   branches/forms-0.5/src/GFInstance.py
   branches/forms-0.5/src/uidrivers/wx26/widgets/_base.py
   branches/forms-0.5/src/uidrivers/wx26/widgets/entry.py
Log:
Fixed focus handling for dropdowns (again the neverending story)


Modified: branches/forms-0.5/src/GFInstance.py
===================================================================
--- branches/forms-0.5/src/GFInstance.py        2006-08-23 06:55:25 UTC (rev 
8605)
+++ branches/forms-0.5/src/GFInstance.py        2006-08-23 09:19:33 UTC (rev 
8606)
@@ -1090,6 +1090,9 @@
     Change the focus to the entry object requested by the event source
     """
 
+    if event.data == event._form._currentEntry:
+        return True
+
     if not event._form.endEditing ():
       return False
 

Modified: branches/forms-0.5/src/uidrivers/wx26/widgets/_base.py
===================================================================
--- branches/forms-0.5/src/uidrivers/wx26/widgets/_base.py      2006-08-23 
06:55:25 UTC (rev 8605)
+++ branches/forms-0.5/src/uidrivers/wx26/widgets/_base.py      2006-08-23 
09:19:33 UTC (rev 8606)
@@ -61,6 +61,7 @@
     if event.initialize:
       self._addToCrossRef (newWidget, self._gfObject, self)
 
+    self._block_focus_ = False
     return newWidget
 
 
@@ -156,7 +157,7 @@
       item = widget
 
     # Only change the focus if necessary
-    if current != item:
+    if current != item and not self._block_focus_:
       item.SetFocus ()
 
 
@@ -240,7 +241,9 @@
     elif hasattr (widget, 'SetInsertionPoint'):
       widget.SetInsertionPoint (self._positionToWx (widget, position))
 
+    widget.Refresh()
 
+
   # --------------------------------------------------------------------------
   # Set the selection inside a widget
   # --------------------------------------------------------------------------
@@ -269,7 +272,9 @@
 
       widget.SetSelection (selection1, selection2)
 
+    widget.Refresh()
 
+
   # ---------------------------------------------------------------------------
   # Update the choices of a ComboBox or a Listbox
   # ---------------------------------------------------------------------------

Modified: branches/forms-0.5/src/uidrivers/wx26/widgets/entry.py
===================================================================
--- branches/forms-0.5/src/uidrivers/wx26/widgets/entry.py      2006-08-23 
06:55:25 UTC (rev 8605)
+++ branches/forms-0.5/src/uidrivers/wx26/widgets/entry.py      2006-08-23 
09:19:33 UTC (rev 8606)
@@ -163,7 +163,10 @@
     item.Bind (wx.EVT_SET_FOCUS, self.__on_set_focus)
 
     # On Mac we don't bind the button release event, as it does not get fired
-    if not 'wxMac' in wx.PlatformInfo:
+    if 'wxMSW' in wx.PlatformInfo:
+        item.Bind(wx.EVT_KEY_DOWN, self.__on_key_down)
+
+    elif not 'wxMac' in wx.PlatformInfo:
       item.Bind (wx.EVT_LEFT_UP, self.__leftMouseUp)
 
     return result
@@ -198,14 +201,8 @@
     count  = self.widgets.index (lookup)
     adjust = count - self._gfObject._visibleIndex
 
-    # Now follows a quite dirty trick. The current widget does not have an
-    # insertion point set yet, which happens after wx.EVT_SET_FOCUS is
-    # processed. Calling a requestFOCUS event sets the insertion point to the
-    # end of the display value (via beginEDIT). So the real insertion point (of
-    # a mouse click for example) always gets lost. To resolve that do all the
-    # dirty work of synchronizing the focus in GF *after* setting the initial
-    # wx-focus.
-    wx.CallAfter (self.__focusWorker, event.GetEventObject (), doFocus, adjust)
+    if doFocus or adjust:
+        self.__focusWorker(event.GetEventObject(), doFocus, adjust)
 
     event.Skip ()
 
@@ -235,7 +232,11 @@
       restore = None
 
     if doFocus:
-      self._request ('FOCUS', data = self._gfObject)
+      try:
+          self._block_focus_ = True
+          self._request ('FOCUS', data = self._gfObject)
+      finally:
+          self._block_focus_ = False
 
     if adjust:
       self._request ('JUMPRECORD', data = adjust)
@@ -356,7 +357,27 @@
       # sync with the position and/or selection
       wx.CallAfter (self.__updateInsertionPoint, event.GetEventObject ())
 
+  # ---------------------------------------------------------------------------
 
+  def __on_key_down(self, event):
+
+      keycode = event.GetKeyCode()
+      if keycode in [wx.WXK_LEFT, wx.WXK_RIGHT, wx.WXK_DELETE]:
+          (command, args) = GFKeyMapper.KeyMapper.getEvent (keycode,
+                event.ShiftDown (),
+                event.CmdDown (),
+                event.AltDown ())
+
+          if command:
+              self._request(command, triggerName=args)
+          else:
+              event.Skip()
+      else:
+          event.Skip()
+    
+
+
+
 # =============================================================================
 # Configuration
 # =============================================================================





reply via email to

[Prev in Thread] Current Thread [Next in Thread]