[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnue] r8619 - in trunk/gnue-forms/src: . uidrivers/wx26/widgets
From: |
johannes |
Subject: |
[gnue] r8619 - in trunk/gnue-forms/src: . uidrivers/wx26/widgets |
Date: |
Thu, 24 Aug 2006 03:14:27 -0500 (CDT) |
Author: johannes
Date: 2006-08-24 03:14:26 -0500 (Thu, 24 Aug 2006)
New Revision: 8619
Modified:
trunk/gnue-forms/src/GFInstance.py
trunk/gnue-forms/src/uidrivers/wx26/widgets/_base.py
trunk/gnue-forms/src/uidrivers/wx26/widgets/entry.py
Log:
Fixed focus and keyboard handling for dropdowns and multiline edits
Modified: trunk/gnue-forms/src/GFInstance.py
===================================================================
--- trunk/gnue-forms/src/GFInstance.py 2006-08-24 07:34:32 UTC (rev 8618)
+++ trunk/gnue-forms/src/GFInstance.py 2006-08-24 08:14:26 UTC (rev 8619)
@@ -966,6 +966,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 ():
# Old focus entry has invalid value: beat the UI focus back, so we are
# captured until the value is corrected.
Modified: trunk/gnue-forms/src/uidrivers/wx26/widgets/_base.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/wx26/widgets/_base.py 2006-08-24
07:34:32 UTC (rev 8618)
+++ trunk/gnue-forms/src/uidrivers/wx26/widgets/_base.py 2006-08-24
08:14:26 UTC (rev 8619)
@@ -102,6 +102,7 @@
self.chr_y = None
self.chr_pos = None
self.chr_span = None
+ self._block_focus_ = False
# -------------------------------------------------------------------------
@@ -246,7 +247,7 @@
item = widget
# Only change the focus if necessary
- if current != item:
+ if current != item and not self._block_focus_:
item.SetFocus()
Modified: trunk/gnue-forms/src/uidrivers/wx26/widgets/entry.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/wx26/widgets/entry.py 2006-08-24
07:34:32 UTC (rev 8618)
+++ trunk/gnue-forms/src/uidrivers/wx26/widgets/entry.py 2006-08-24
08:14:26 UTC (rev 8619)
@@ -170,9 +170,12 @@
item.Bind(wx.EVT_CHAR, self.__on_keypress)
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:
+ # On MSW we don't get all keys in wx.EVT_CHAR, so we have to bind keyup
+ if 'wxMSW' in wx.PlatformInfo:
+ item.Bind(wx.EVT_KEY_DOWN, self.__on_msw_keydown)
+
+ # The button release event is fired on wxGTK only
+ elif 'wxGTK' in wx.PlatformInfo:
item.Bind(wx.EVT_LEFT_UP, self.__on_left_mouseup)
return [self.__add_entry_label(parent), result]
@@ -262,15 +265,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.__focus_worker, event.GetEventObject(), do_focus,
- adjust)
+ if do_focus or adjust:
+ self.__focus_worker(event.GetEventObject(), do_focus, adjust)
event.Skip()
@@ -328,10 +324,17 @@
gDebug(2, "__on_keypress: %s %s" % (keycode, unikey))
- (command, args) = GFKeyMapper.KeyMapper.getEvent(keycode,
- event.ShiftDown(),
- event.CmdDown(),
- event.AltDown())
+ # Prevent up- and down-keys for multiline text controls from being
+ # interpreted as record-navigation-keys.
+ wxctrl = event.GetEventObject()
+ if isinstance(wxctrl, wx.TextCtrl) and wxctrl.IsMultiLine() \
+ and keycode in [wx.WXK_UP, wx.WXK_DOWN]:
+ command = None
+ else:
+ (command, args) = GFKeyMapper.KeyMapper.getEvent(keycode,
+ event.ShiftDown(),
+ event.CmdDown(),
+ event.AltDown())
# This is a temporary workaround: since the KeyMapper encapsulates all
# unknown keys into a UserCommand we have no chance on Mac to enter
@@ -358,7 +361,25 @@
# in sync with the position and/or selection.
wx.CallAfter(self.__update_insertion_point, event.GetEventObject())
+ # -------------------------------------------------------------------------
+ def __on_msw_keydown(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()
+
+
# -------------------------------------------------------------------------
# Do the dirty work for moving the focus and adjusting the row
# -------------------------------------------------------------------------
@@ -383,8 +404,13 @@
restore = None
if do_focus:
- 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)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnue] r8619 - in trunk/gnue-forms/src: . uidrivers/wx26/widgets,
johannes <=