commit-gnue
[Top][All Lists]
Advanced

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

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


From: reinhard
Subject: [gnue] r8855 - trunk/gnue-forms/src
Date: Wed, 18 Oct 2006 13:21:05 -0500 (CDT)

Author: reinhard
Date: 2006-10-18 13:21:05 -0500 (Wed, 18 Oct 2006)
New Revision: 8855

Modified:
   trunk/gnue-forms/src/GFForm.py
   trunk/gnue-forms/src/GFInstance.py
Log:
Moved record navigation that results from focus navigation (tabbing to
next/previous record) between focus-out and focus-in, so focus triggers and all
that other logic runs in the correct order.


Modified: trunk/gnue-forms/src/GFForm.py
===================================================================
--- trunk/gnue-forms/src/GFForm.py      2006-10-18 16:36:20 UTC (rev 8854)
+++ trunk/gnue-forms/src/GFForm.py      2006-10-18 18:21:05 UTC (rev 8855)
@@ -814,22 +814,14 @@
           # If we should navigate to the next record, do it...
           if currentBlock is not None \
                   and reverse and not currentBlock.is_first_record():
-            currentBlock.prev_record()
-            self.changeFocus(nextEntry)
+            self.changeFocus(nextEntry, -1)
           elif currentBlock is not None and not reverse and \
              currentBlock.autoNextRecord and \
              not currentBlock.is_empty() and \
              not (not currentBlock.autoCreate and \
                   currentBlock.is_last_record()):
-               currentBlock.next_record()
+               self.changeFocus(nextEntry, +1)
 
-               # If new record is empty, then the
-               # nextEntry logic has been taken care of...
-               if currentBlock.is_empty():
-                 return
-               else:
-                 self.changeFocus(nextEntry)
-
           # Otherwise, are we transparent? If so, go to next block/page
           elif (currentBlock is None or currentBlock.transparent) and \
              self._currentPage.transparent:
@@ -852,10 +844,10 @@
                 dest = self._layout._pageList[0]
               self.findAndChangeFocus(dest)
           else:
-            self.changeFocus(nextEntry)
+            self.changeFocus(nextEntry, 0)
 
         else:
-          self.changeFocus(nextEntry)
+          self.changeFocus(nextEntry, 0)
 
     # -------------------------------------------------------------------------
 
@@ -945,7 +937,7 @@
 
         entry = self.findFocus(object)
         if entry:
-            self.changeFocus(entry)
+            self.changeFocus(entry, 0)
 
 
     # -------------------------------------------------------------------------
@@ -1015,7 +1007,7 @@
     # Changes to the requested entry object requested by an event source
     # -------------------------------------------------------------------------
 
-    def changeFocus(self, widget):
+    def changeFocus(self, widget, row_offset):
         """
         Changes focus to the requested entry object on GF and UI layer.
 
@@ -1027,7 +1019,7 @@
         if self._currentEntry is not None:
             self._currentEntry.ui_focus_out()
         try:
-            self.move_focus(widget)
+            self.move_focus(widget, row_offset)
             if self._currentPage != old_page:
                 self.uiWidget._ui_goto_page_(self._currentPage.uiWidget)
         finally:
@@ -1039,11 +1031,12 @@
     # Changes to the requested entry object requested by an event source
     # -------------------------------------------------------------------------
 
-    def move_focus(self, widget):
+    def move_focus(self, widget, row_offset):
         """
         Changes focus to the requested entry object on GF layer.
 
         @param widget: entry to put focus on
+        @param row_offset: number of rows to jump up or down in new widget
         """
 
         # cannot change focus to same entry
@@ -1053,9 +1046,14 @@
 
         assert gDebug(5, "Change focus: %s->%s" % (self._currentEntry, widget))
 
-        blockChange = (widget.get_block() != self._currentBlock)
-        pageChange = (widget._page != self._currentPage)
+        new_block = widget.get_block()
+        new_page = widget._page
 
+        # if we move the record pointer, we also want to run the block-level
+        # focus in and focus out triggers
+        blockChange = (new_block != self._currentBlock) or row_offset != 0
+        pageChange = (new_page != self._currentPage)
+
         if self._currentEntry:          # do not run on initial changeFocus
 
             # Validation triggers
@@ -1066,7 +1064,8 @@
             if field is not None:
                 field.validate()
             if blockChange:
-                self._currentBlock.validate()
+                if self._currentBlock is not None:
+                    self._currentBlock.validate()
 
             # Focus-Out triggers
             self._currentEntry.focus_out()
@@ -1076,16 +1075,28 @@
             if field is not None:
                 field.focus_out()
             if blockChange:
-                self._currentBlock.focus_out()
+                if self._currentBlock is not None:
+                    self._currentBlock.focus_out()
 
+        # Set Focus to nowhere while we move the record pointer, so no focus
+        # magic will happen now.
+        self._currentEntry = None
+        self._currentBlock = None
+
+        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)
+
         self._currentEntry = widget
-        if self._currentEntry.get_block() is not None:
-            self._currentBlock = self._currentEntry.get_block()
-        self._currentPage = self._currentEntry._page
+        self._currentBlock = new_block
+        self._currentPage = new_page
 
         # Focus-In triggers
         if blockChange:
-            self._currentBlock.focus_in()
+            if self._currentBlock is not None:
+                self._currentBlock.focus_in()
         field = self._currentEntry.get_field()
         if field is not None:
             field.focus_in()

Modified: trunk/gnue-forms/src/GFInstance.py
===================================================================
--- trunk/gnue-forms/src/GFInstance.py  2006-10-18 16:36:20 UTC (rev 8854)
+++ trunk/gnue-forms/src/GFInstance.py  2006-10-18 18:21:05 UTC (rev 8855)
@@ -444,7 +444,7 @@
     try:
       event._form.endEditing()
       try:
-        event._form.move_focus(event.data)
+        event._form.move_focus(event.data, 0)
       finally:
         event._form.beginEditing()
 
@@ -454,7 +454,8 @@
       # Old focus entry has invalid value: beat the UI focus back, so we are
       # captured until the value is corrected.
       event._form._currentEntry.ui_focus_in()
-      event._form._currentEntry._displayHandler.generateRefreshEvent()
+      if hasattr(event._form._currentEntry, '_displayHandler'):
+        event._form._currentEntry._displayHandler.generateRefreshEvent()
       raise
 
 





reply via email to

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