commit-gnue
[Top][All Lists]
Advanced

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

[gnue] r8987 - trunk/gnue-forms/src


From: reinhard
Subject: [gnue] r8987 - trunk/gnue-forms/src
Date: Tue, 7 Nov 2006 12:15:52 -0600 (CST)

Author: reinhard
Date: 2006-11-07 12:15:51 -0600 (Tue, 07 Nov 2006)
New Revision: 8987

Modified:
   trunk/gnue-forms/src/GFForm.py
Log:
Don't call endEditing and beginEditing if the current record is changed from a
focusin/out trigger.


Modified: trunk/gnue-forms/src/GFForm.py
===================================================================
--- trunk/gnue-forms/src/GFForm.py      2006-11-07 17:18:58 UTC (rev 8986)
+++ trunk/gnue-forms/src/GFForm.py      2006-11-07 18:15:51 UTC (rev 8987)
@@ -91,6 +91,10 @@
         self._currentBlock = None
         self._currentEntry = None
 
+        # Set to true while focus is moving so a record change in
+        # focusin/focusout triggers doesn't run endEditing and beginEditing
+        self.__focus_moving = False
+
         self._instance = instance
 
         # Hackery until proper layout support is added
@@ -1089,56 +1093,61 @@
         blockChange = (new_block != self._currentBlock) or row_offset != 0
         pageChange = (new_page != self._currentPage)
 
-        if self._currentEntry:            
-            # Validation triggers
-            self._currentEntry.validate()
-            if pageChange:
-                self._currentPage.validate()
-            field = self._currentEntry.get_field()
-            if field is not None:
-                field.validate()
-            if blockChange:
-                if self._currentBlock is not None:
-                    self._currentBlock.validate()
+        self.__focus_moving = True
 
-            # Focus-Out triggers
-            self._currentEntry.focus_out()
-            if pageChange:
-                self._currentPage.focus_out()
-            field = self._currentEntry.get_field()
-            if field is not None:
-                field.focus_out()
-            if blockChange:
-                if self._currentBlock is not None:
-                    self._currentBlock.focus_out()
+        try:
+            if self._currentEntry:            
+                # Validation triggers
+                self._currentEntry.validate()
+                if pageChange:
+                    self._currentPage.validate()
+                field = self._currentEntry.get_field()
+                if field is not None:
+                    field.validate()
+                if blockChange:
+                    if self._currentBlock is not None:
+                        self._currentBlock.validate()
 
-        # Set Focus to nowhere while we move the record pointer, so no focus
-        # magic will happen now.
-        self._currentEntry = None
-        self._currentBlock = None
+                # Focus-Out triggers
+                self._currentEntry.focus_out()
+                if pageChange:
+                    self._currentPage.focus_out()
+                field = self._currentEntry.get_field()
+                if field is not None:
+                    field.focus_out()
+                if blockChange:
+                    if self._currentBlock is not None:
+                        self._currentBlock.focus_out()
 
-        if row_offset == 1:
-            # Special case: next_record() can also trigger a new_record()
-            new_block.next_record()
-        elif row_offset != 0:
-            new_block.jump_records(row_offset)
+            # Set Focus to nowhere while we move the record pointer, so no 
focus
+            # magic will happen now.
+            self._currentEntry = None
+            self._currentBlock = None
 
-        self._currentEntry = widget
-        self._currentBlock = new_block
-        self._currentPage = new_page
+            if row_offset == 1:
+                # Special case: next_record() can also trigger a new_record()
+                new_block.next_record()
+            elif row_offset != 0:
+                new_block.jump_records(row_offset)
 
-        # Focus-In triggers
-        if self._currentEntry is not None:
-            if blockChange:
-                if self._currentBlock is not None:
-                    self._currentBlock.focus_in()
-            field = self._currentEntry.get_field()
-            if field is not None:
-                field.focus_in()
-            if pageChange:
-                self._currentPage.focus_in()
-            self._currentEntry.focus_in()
+            self._currentEntry = widget
+            self._currentBlock = new_block
+            self._currentPage = new_page
 
+            # Focus-In triggers
+            if self._currentEntry is not None:
+                if blockChange:
+                    if self._currentBlock is not None:
+                        self._currentBlock.focus_in()
+                field = self._currentEntry.get_field()
+                if field is not None:
+                    field.focus_in()
+                if pageChange:
+                    self._currentPage.focus_in()
+                self._currentEntry.focus_in()
+        finally:
+            self.__focus_moving = False
+
         # The Focus-In trigger of the block has already refreshed the toolbar,
         # except for the case where the new entry has no block.
         if self._currentBlock is None:
@@ -1792,7 +1801,7 @@
         save it's value to the virtual form.
         @return: Boolean, True if succeeded, False if failed.
         """
-        if isinstance(self._currentEntry, GFEntry):
+        if not self.__focus_moving and isinstance(self._currentEntry, GFEntry):
             self._currentEntry.endEdit()
 
 
@@ -1801,7 +1810,7 @@
     # -------------------------------------------------------------------------
 
     def beginEditing(self):
-        if isinstance(self._currentEntry, GFEntry):
+        if not self.__focus_moving and isinstance(self._currentEntry, GFEntry):
             self._currentEntry.beginEdit()
 
 





reply via email to

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