[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnue] r9083 - trunk/gnue-forms/src
From: |
reinhard |
Subject: |
[gnue] r9083 - trunk/gnue-forms/src |
Date: |
Tue, 28 Nov 2006 12:30:48 -0600 (CST) |
Author: reinhard
Date: 2006-11-28 12:30:48 -0600 (Tue, 28 Nov 2006)
New Revision: 9083
Modified:
trunk/gnue-forms/src/GFForm.py
Log:
Jump over blocks that don't have navigable entries in next_block() and
prev_block().
issue36 testing
Modified: trunk/gnue-forms/src/GFForm.py
===================================================================
--- trunk/gnue-forms/src/GFForm.py 2006-11-28 18:28:43 UTC (rev 9082)
+++ trunk/gnue-forms/src/GFForm.py 2006-11-28 18:30:48 UTC (rev 9083)
@@ -304,7 +304,7 @@
# of the datasource), otherwise a dropdown will be set to edit mode
# before it has been populated with the allowed values, in case the
# first entry on the form is a dropdown.
- self.__find_and_change_focus(self, False)
+ self.__find_and_change_focus([self], False)
self.update_insert_status()
@@ -383,7 +383,7 @@
self._currentPage = self._layout._pageList[page_number]
self._currentPage.focus_in()
- self.__find_and_change_focus(self._currentPage, False)
+ self.__find_and_change_focus([self._currentPage], False)
# -------------------------------------------------------------------------
@@ -491,7 +491,7 @@
self._in_trigger_lock = True
try:
- self.__find_and_change_focus(object._object, False)
+ self.__find_and_change_focus([object._object], False)
finally:
self._in_trigger_lock = False
@@ -879,21 +879,10 @@
self._currentPage.transparent:
# Jump to the next/(previous) page if block is page as transparent
- pages = self._layout._pageList
+ 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]
- self.__find_and_change_focus(dest, True)
- else:
- try:
- dest = self._layout._pageList[i + 1]
- except IndexError:
- dest = self._layout._pageList[0]
- self.__find_and_change_focus(dest, False)
+ list = pages[i+1:] + pages[:i]
+ self.__find_and_change_focus(list, reverse)
else:
self.change_focus(nextEntry, 0)
@@ -921,16 +910,12 @@
@return: None
"""
- blocks = self._logic._blockList
if self._currentBlock is not None:
+ # Find next block with navigable entries.
+ blocks = self._logic._blockList
current_index = blocks.index(self._currentBlock)
- if current_index == len(blocks) - 1:
- next_index = 0
- else:
- next_index = current_index + 1
- self.__find_and_change_focus(blocks[next_index], False)
- else:
- self.__find_and_change_focus(blocks[0], False)
+ list = blocks[current_index+1:] + blocks[:current_index]
+ self.__find_and_change_focus(list, False)
# -------------------------------------------------------------------------
@@ -940,12 +925,13 @@
@return: None
"""
- blocks = self._logic._blockList
if self._currentBlock is not None:
- self.__find_and_change_focus(blocks[blocks.index(
- self._currentBlock) - 1], False)
- else:
- self.__find_and_change_focus(blocks[-1], False)
+ # Find next block with navigable entries.
+ blocks = self._logic._blockList
+ current_index = blocks.index(self._currentBlock)
+ list = blocks[current_index+1:] + blocks[:current_index]
+ list.reverse()
+ self.__find_and_change_focus(list, False)
# -------------------------------------------------------------------------
@@ -963,7 +949,7 @@
next_index = 0
else:
next_index = current_index + 1
- self.__find_and_change_focus(pages[next_index], False)
+ self.__find_and_change_focus([pages[next_index]], False)
# -------------------------------------------------------------------------
@@ -973,7 +959,7 @@
"""
pages = self._layout._pageList
- self.__find_and_change_focus(pages[pages.index(self._currentPage) - 1],
+ self.__find_and_change_focus([pages[pages.index(self._currentPage)-1]],
False)
@@ -981,50 +967,50 @@
# Move the focus to a new object
# -------------------------------------------------------------------------
- def __find_and_change_focus(self, object, last):
+ def __find_and_change_focus(self, list, last):
- entry = self.__find_focus(object, last)
+ entry = self.__find_focus(list, last)
if entry:
self.change_focus(entry, 0)
# -------------------------------------------------------------------------
- # Find the next focusable item within a container
+ # Find the next focusable item within a list of objects
# -------------------------------------------------------------------------
- def __find_focus(self, object, last):
+ def __find_focus(self, list, last):
- if isinstance(object, GFTabStop):
- # Trivial case: the focus object itself.
- if object.is_navigable(self.getCurrentMode()):
- return object
- else:
- return None
+ if last:
+ list = list[:] # Don't mess with the parameter!
+ list.reverse()
- elif isinstance(object, GFContainer):
- # Container: search for the first focusable object.
- list = object.get_focus_order()
+ for object in list:
+ if isinstance(object, GFTabStop):
+ # Trivial case: the focus object itself.
+ if object.is_navigable(self.getCurrentMode()):
+ return object
+ else:
+ continue
- elif isinstance(object, GFField):
- # Field: search for the first focusable entry attached to it.
- list = object._entryList
+ elif isinstance(object, GFContainer):
+ # Container: search for the first focusable object.
+ new_list = object.get_focus_order()
- else:
- # If the object is neither a TabStop or a Container search for a
- # container object and try to retrieve a focus object from it. We
- # are looking for the visual items first, and then fall back to the
- # blocks.
- list = object.findChildrenOfType('GFPage', False, True) \
- + object.findChildrenOfType('GFBox', False, True) \
- + object.findChildrenOfType('GFBlock', False, True)
+ elif isinstance(object, GFField):
+ # Field: search for the first focusable entry attached to it.
+ new_list = object._entryList
- # Reverse the list to search if we are searching the last entry.
- if last:
- list.reverse()
+ else:
+ # If the object is neither a TabStop or a Container search for
+ # a container object and try to retrieve a focus object from
+ # it. We are looking for the visual items first, and then fall
+ # back to the blocks.
+ # FIXME: I think we want to deprecate this.
+ new_list = object.findChildrenOfType('GFPage', False, True) \
+ + object.findChildrenOfType('GFBox', False, True) \
+ + object.findChildrenOfType('GFBlock', False, True)
- # Return the first object that can receive the focus.
- for item in list:
- new_focus = self.__find_focus(item, last)
+ new_focus = self.__find_focus(new_list, last)
if new_focus:
return new_focus
@@ -1136,7 +1122,6 @@
# Special case: next_record() can also trigger a new_record()
new_block.next_record()
elif row_offset != 0:
- print "ROW-OFFSET:", row_offset
new_block.jump_records(row_offset)
self._currentEntry = widget
@@ -1484,7 +1469,7 @@
# FIXME: does not work with master/detail, always moves the
# focus to master record.
if block != self._currentBlock:
- self.__find_and_change_focus(block, False)
+ self.__find_and_change_focus([block], False)
raise
finally:
for block in self._logic._blockList:
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnue] r9083 - trunk/gnue-forms/src,
reinhard <=