commit-gnue
[Top][All Lists]
Advanced

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

r5060 - trunk/gnue-forms/src


From: jcater
Subject: r5060 - trunk/gnue-forms/src
Date: Fri, 30 Jan 2004 19:33:14 -0600 (CST)

Author: jcater
Date: 2004-01-30 19:33:13 -0600 (Fri, 30 Jan 2004)
New Revision: 5060

Modified:
   trunk/gnue-forms/src/GFForm.py
Log:
simplified/consolidated the nextEntry/prevEntry code

Modified: trunk/gnue-forms/src/GFForm.py
===================================================================
--- trunk/gnue-forms/src/GFForm.py      2004-01-31 01:32:25 UTC (rev 5059)
+++ trunk/gnue-forms/src/GFForm.py      2004-01-31 01:33:13 UTC (rev 5060)
@@ -574,6 +574,9 @@
       self.dispatchEvent('updateENTRY',entry, _form=self)
       #self._instance.dispatchEvent('updateENTRY',entry, _form=self)
 
+  #
+  # 
+  # 
 
   #
   # nextEntry
@@ -581,43 +584,65 @@
   # Called whenever an event source has requested that the
   # focus change to the next data entry object
   #
-  def nextEntry(self):
-    nextEntry = None
-    firstEntry = None
-    keepNext = False
+  def nextEntry(self, reverse=False, first=False, onlyInBlock=False):
 
-
-    if self._currentBlock.transparent:
-      source = self._currentEntry._page._focusOrder
+    if self._currentBlock.transparent and not onlyInBlock:
+      source = self._currentEntry._page._focusOrder[:]
     else:
-      source = self._currentBlock._focusOrder
+      source = self._currentBlock._focusOrder[:]
 
-    # if self._currentEntry._page.transparent:
-
+    # If we want the previous entry, then reverse the focusorder we're using
+    if reverse: 
+      source.reverse()
+      
+    nextEntry = None
+    firstEntry = None
+    keepNext = False
     for object in source:
-      # Put the first field as the next to rollover
+      
       if ((object._navigable) and ((not object.readonly) or
          (self._currentBlock.mode=='query' and object._queryable))):
+         
+        # If we only wanted the first navigable field in the block, then return
+        if first: 
+          nextEntry = object
+          break
+      
+        # Put the first field as the next to rollover
         if nextEntry == None:
           nextEntry = object
           firstEntry = object
 
+        # If we're at the current focused entry, 
+        # then the next entry will be what we want
         if object == self._currentEntry:
           keepNext = True
-          continue
 
-        if keepNext:
+        # If we've already passed the current entry
+        # Then this is the entry to return
+        elif keepNext:
           nextEntry = object
           break
 
     if nextEntry == firstEntry and self._currentBlock.transparent and 
self._currentPage.transparent:
-      # Jump to the next page if block is page as transparent
-      i = self._layout._pageList.index(self._currentPage)
-      try:
-        dest = self._layout._pageList[i+1]
-      except IndexError:
-        dest = self._layout._pageList[0]
-      self.findAndChangeFocus(dest)
+      # Jump to the next/(previous) page if block is page as transparent
+      pages =  self._layout._pageList
+      i = pages.index(self._currentPage)
+      
+      if reverse: 
+        try:
+          dest = self._layout._pageList[i-1]
+        except IndexError:
+          dest = self._layout._pageList[-1]
+        # TODO: this fails if last entry is not navigable
+        self.findAndChangeFocus(dest._entryList[-1])
+      else:
+        try:
+          dest = self._layout._pageList[i+1]
+        except IndexError:
+          dest = self._layout._pageList[0]
+        self.findAndChangeFocus(dest)
+        
     else:
       self.changeFocus(nextEntry)
 
@@ -628,49 +653,8 @@
   # focus change to the next data entry object
   #
   def previousEntry(self):
-    # find last entry widget
-    nextEntry = None
-    lastEntry = self._currentEntry
+    return self.nextEntry(reverse=True)
 
-    if self._currentBlock.transparent:
-      source = self._currentEntry._page._focusOrder
-    else:
-      source = self._currentBlock._focusOrder
-
-    #
-    # Find the last focusable entry in the focus list
-    #
-    for object in source:
-      if ((object._navigable) and ((not object.readonly) or
-         (self._currentBlock.mode=='query' and object._queryable))):
-        nextEntry = object
-        lastEntry = object
-        
-    #
-    # Find the first navigable field prior to the
-    # field losing focus
-    #
-    keepNext = False
-    for object in source:
-      # Put the first field as the next to rollover
-      if ((object._navigable) and (not object.hidden) and ((not 
object.readonly) or
-         (self._currentBlock.mode=='query' and object._queryable))):
-        if object == self._currentEntry:
-          break
-
-        nextEntry = object
-
-    if nextEntry == lastEntry and self._currentBlock.transparent and 
self._currentPage.transparent:
-      i = self._layout._pageList.index(self._currentPage)
-      try:
-        dest = self._layout._pageList[i - 1]
-      except IndexError:
-        dest = self._layout._pageList[-1]
-      # TODO: This fails if last entry is not navigable
-      self.findAndChangeFocus(dest._entryList[-1])
-    else:
-      self.changeFocus(nextEntry)
-
   #
   # refreshDisplay
   #





reply via email to

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