[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnue] r9256 - trunk/gnue-forms/src/input/displayHandlers
From: |
reinhard |
Subject: |
[gnue] r9256 - trunk/gnue-forms/src/input/displayHandlers |
Date: |
Wed, 10 Jan 2007 08:41:30 -0600 (CST) |
Author: reinhard
Date: 2007-01-10 08:41:29 -0600 (Wed, 10 Jan 2007)
New Revision: 9256
Modified:
trunk/gnue-forms/src/input/displayHandlers/Cursor.py
Log:
Added some comments and a minor structure improvement.
Modified: trunk/gnue-forms/src/input/displayHandlers/Cursor.py
===================================================================
--- trunk/gnue-forms/src/input/displayHandlers/Cursor.py 2007-01-10
14:40:56 UTC (rev 9255)
+++ trunk/gnue-forms/src/input/displayHandlers/Cursor.py 2007-01-10
14:41:29 UTC (rev 9256)
@@ -64,7 +64,7 @@
self.field = entry._field # The GFField associated with that
GFEntry
self.editing = False # Is handler in edit mode
self.modified = False # Have we been modified??
- self.updating = False # Is an updateFieldValue already running
+ self.__updating = False # Is an updateFieldValue already running
self.display = u"" # The current display-formatted value
self.subEventHandler = subEventHandler
@@ -159,11 +159,12 @@
"""
self.editing = self.field.is_editable(0)
self.modified = False
- self.display = self.build_display(self.field.get_value(), True)
+ self.display = self.build_display(self.field.get_value(), self.editing)
self._cursor = len(self.display)
self.setSelectionArea(0, self._cursor)
self.generateRefreshEvent()
+
def endEdit(self):
"""
Called when a widget loses focus or when ENTER is hit.
@@ -171,23 +172,14 @@
if not self.editing:
return
- # Set editing to False early. The later call to __updateFieldValue()
- # can, if it is an autoquery field, cause a query to run, in which case
- # editing should not be True at that moment.
+ self.__updateFieldValue()
self._selection1 = None
+ self.editing = False
+ # Refresh display to switch from editing format to display format.
+ self.generateRefreshEvent()
- if self.modified:
- self.__updateFieldValue()
- self.editing = False
- else:
- # If we don't have to update the field value, we need to refresh
- # the display, because the selection has been deleted, and the
- # display string could be different from editing to non-editing.
- self.editing = False
- self.generateRefreshEvent()
-
# -------------------------------------------------------------------------
# Text manipulation
# -------------------------------------------------------------------------
@@ -339,15 +331,9 @@
# Update the field. This means PRE-CHANGE and POST-CHANGE will get
# fired now. For now, only do this here if we are a lookup.
if hasattr(self.field, 'fk_source'):
- try:
- self.__updateFieldValue()
+ self.updateFieldValue()
- except Exception:
- # We don't care about exceptions now, the user can still
- # correct the mistake
- pass
-
# =========================================================================
# Cursor movement functions
# =========================================================================
@@ -573,23 +559,27 @@
def updateFieldValue (self):
"""
Update the associated field with the current value of the display
- handler.
+ handler. Exceptions are ignored. This function is used to update the
+ underlying field while the entry remains in editing mode (so the user
+ still can correct errors).
"""
+ try:
+ self.__updateFieldValue()
+ except:
+ pass
- if self.isPending():
- try:
- self.__updateFieldValue()
- except:
- pass
def __updateFieldValue(self):
- if not self.updating:
- self.updating = True
+ if not self.__updating and self.isPending():
+ # Make sure that this function isn't called twice recursively. This
+ # would happen when the field is autoquery, so the
+ # field.set_value() would cause a query to run, which in turns
+ # causes an endEdit.
+ self.__updating = True
try:
value = self.parse_display(self.display)
self.field.set_value(value)
self.modified = False
-
finally:
- self.updating = False
+ self.__updating = False
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnue] r9256 - trunk/gnue-forms/src/input/displayHandlers,
reinhard <=