[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnue] r8793 - in trunk/gnue-forms/src: . GFObjects
From: |
reinhard |
Subject: |
[gnue] r8793 - in trunk/gnue-forms/src: . GFObjects |
Date: |
Mon, 16 Oct 2006 06:57:12 -0500 (CDT) |
Author: reinhard
Date: 2006-10-16 06:57:10 -0500 (Mon, 16 Oct 2006)
New Revision: 8793
Modified:
trunk/gnue-forms/src/GFForm.py
trunk/gnue-forms/src/GFInstance.py
trunk/gnue-forms/src/GFObjects/GFTabStop.py
Log:
Replaced GFForm.adjust_ui_focus() by two distinct methods
GFTabStop.ui_focus_[in|out]().
Modified: trunk/gnue-forms/src/GFForm.py
===================================================================
--- trunk/gnue-forms/src/GFForm.py 2006-10-16 10:10:36 UTC (rev 8792)
+++ trunk/gnue-forms/src/GFForm.py 2006-10-16 11:57:10 UTC (rev 8793)
@@ -90,10 +90,6 @@
self._currentBlock = None
self._currentEntry = None
- # Last focused widget (state of the UI)
- self.__last_focus_object = None
- self.__last_focus_index = None
-
self._instance = instance
# Hackery until proper layout support is added
@@ -413,8 +409,9 @@
if not focus._type in ['GFEntry', 'GFButton']:
raise "setFocus failed: Can just switch to GFEntry objects. " +\
"You passed a '%s' object." % focus._type
+ self._currentEntry.ui_focus_out()
self.changeFocus(focus)
- self.adjust_ui_focus()
+ self._currentEntry.ui_focus_in()
self._in_trigger_lock = False
# -------------------------------------------------------------------------
@@ -714,10 +711,10 @@
entry = self.findFocus(object)
if entry:
- # Set focus on GF layer
+ if self._currentEntry is not None:
+ self._currentEntry.ui_focus_out()
self.changeFocus(entry)
- # Set focus on UI layer
- self.adjust_ui_focus()
+ self._currentEntry.ui_focus_in()
# -------------------------------------------------------------------------
@@ -878,31 +875,6 @@
# -------------------------------------------------------------------------
- # Adjust the focus in the user interface
- # -------------------------------------------------------------------------
-
- def adjust_ui_focus(self):
- """
- Adjust the focusin the user interface to where the form thinks the
- focus should be.
-
- This function has to be called after the focus has moved to a different
- widget or to a different row within the same widget.
- """
-
- if self.__last_focus_object:
- self.__last_focus_object.uiWidget._ui_lose_focus_(
- self.__last_focus_index)
- self._currentEntry.uiWidget._ui_set_focus_(
- self._currentEntry._visibleIndex)
- if hasattr(self._currentEntry, '_displayHandler') \
- and self._currentEntry._displayHandler.editing:
- self._currentEntry._displayHandler.generateRefreshEvent()
- self.__last_focus_object = self._currentEntry
- self.__last_focus_index = self._currentEntry._visibleIndex
-
-
- # -------------------------------------------------------------------------
# Info about focus position
# -------------------------------------------------------------------------
Modified: trunk/gnue-forms/src/GFInstance.py
===================================================================
--- trunk/gnue-forms/src/GFInstance.py 2006-10-16 10:10:36 UTC (rev 8792)
+++ trunk/gnue-forms/src/GFInstance.py 2006-10-16 11:57:10 UTC (rev 8793)
@@ -440,16 +440,20 @@
except:
# Old focus entry has invalid value: beat the UI focus back, so we are
# captured until the value is corrected.
- event._form.adjust_ui_focus()
+ event._form._currentEntry.ui_focus_in()
+ event._form._currentEntry._displayHandler.generateRefreshEvent()
raise
if event.data._type in ['GFEntry', 'GFImage', 'GFButton']:
if not event.data.is_navigable (event._form.getCurrentMode ()):
return False
+ event._form._currentEntry.ui_focus_out()
+
event._form.changeFocus(event.data)
- event._form.adjust_ui_focus()
+ event._form._currentEntry.ui_focus_in()
+
event._form.beginEditing()
event._form.update_record_status()
@@ -478,8 +482,9 @@
# If the trigger changed focus, no need in us doing it too...
if origEntry == event._form._currentEntry:
+ event._form._currentEntry.ui_focus_out()
event._form.nextEntry()
- event._form.adjust_ui_focus()
+ event._form._currentEntry.ui_focus_in()
event._form.beginEditing()
event._form.update_record_status()
@@ -506,8 +511,9 @@
# If the trigger changed focus, no need in us doing it too...
if origEntry == event._form._currentEntry:
+ event._form._currentEntry.ui_focus_out()
event._form.previousEntry()
- event._form.adjust_ui_focus()
+ event._form._currentEntry.ui_focus_in()
event._form.beginEditing()
event._form.update_record_status()
Modified: trunk/gnue-forms/src/GFObjects/GFTabStop.py
===================================================================
--- trunk/gnue-forms/src/GFObjects/GFTabStop.py 2006-10-16 10:10:36 UTC (rev
8792)
+++ trunk/gnue-forms/src/GFObjects/GFTabStop.py 2006-10-16 11:57:10 UTC (rev
8793)
@@ -161,60 +161,81 @@
if self.hidden:
return
- old_visible_index = self._visibleIndex
+ if self._form.get_focus_object() is self:
+ self.ui_focus_out()
+ try:
+ old_visible_index = self._visibleIndex
- index = min(max(self._visibleIndex + adjustment, 0),
- int(self._rows)-1)
+ index = min(max(self._visibleIndex + adjustment, 0),
+ int(self._rows)-1)
- # Don't let the index pass the number of records
- lowestVisible = max(cur_record - index, 0)
- if lowestVisible + index > rec_count:
- index = index -1
+ # Don't let the index pass the number of records
+ lowestVisible = max(cur_record - index, 0)
+ if lowestVisible + index > rec_count:
+ index = index -1
- # If the current record has rolled around from the top to the
- # bottom then reset the counter.
- if cur_record == 0:
- index = 0
+ # If the current record has rolled around from the top to the
+ # bottom then reset the counter.
+ if cur_record == 0:
+ index = 0
- self._visibleIndex = index
+ self._visibleIndex = index
- if self.uiWidget is not None:
- last_enabled_row = self._visibleIndex + \
- (rec_count - cur_record) - 1
- last_enabled_row = min(last_enabled_row, self._rows - 1)
+ if self.uiWidget is not None:
+ last_enabled_row = self._visibleIndex + \
+ (rec_count - cur_record) - 1
+ last_enabled_row = min(last_enabled_row, self._rows - 1)
- # Disable rows if necessary
- for i in range(last_enabled_row + 1, self.__last_enabled_row + 1):
- self.uiWidget._ui_disable_(i)
+ # Disable rows if necessary
+ for i in range(last_enabled_row+1, self.__last_enabled_row+1):
+ self.uiWidget._ui_disable_(i)
- # Enable rows if necessary
- for i in range(self.__last_enabled_row + 1, last_enabled_row + 1):
- self.uiWidget._ui_enable_(i)
+ # Enable rows if necessary
+ for i in range(self.__last_enabled_row+1, last_enabled_row+1):
+ self.uiWidget._ui_enable_(i)
- self.__last_enabled_row = last_enabled_row
+ self.__last_enabled_row = last_enabled_row
- first_visible_record = cur_record - self._visibleIndex
- if first_visible_record != self.__first_visible_record:
- # If we have scrolled, redisplay all records
- refresh_start = 0
- self.__first_visible_record = first_visible_record
- else:
- if refresh == 'all':
+ first_visible_record = cur_record - self._visibleIndex
+ if first_visible_record != self.__first_visible_record:
+ # If we have scrolled, redisplay all records
refresh_start = 0
- elif refresh == 'current':
- refresh_start = max(old_visible_index, self._visibleIndex)
+ self.__first_visible_record = first_visible_record
else:
- refresh_start = None
+ if refresh == 'all':
+ refresh_start = 0
+ elif refresh == 'current':
+ refresh_start = max(old_visible_index,
self._visibleIndex)
+ else:
+ refresh_start = None
- if isinstance(self, GFFieldBound) and refresh_start is not None:
- self.refresh_ui(refresh_start, self._rows - 1)
+ if isinstance(self, GFFieldBound) and refresh_start is not
None:
+ self.refresh_ui(refresh_start, self._rows - 1)
+ finally:
# If this was the currently focused widget, move the focus along
- if self._visibleIndex != old_visible_index \
- and self._form.get_focus_object() is self:
- self._form.adjust_ui_focus()
+ if self._form.get_focus_object() is self:
+ self.ui_focus_in()
+ if hasattr(self, '_displayHandler') \
+ and self._displayHandler.editing:
+ self._displayHandler.generateRefreshEvent()
+ # -------------------------------------------------------------------------
+ # UI focus movement
+ # -------------------------------------------------------------------------
+
+ def ui_focus_in(self):
+
+ self.uiWidget._ui_set_focus_(self._visibleIndex)
+
+ # -------------------------------------------------------------------------
+
+ def ui_focus_out(self):
+
+ self.uiWidget._ui_lose_focus_(self._visibleIndex)
+
+
# =============================================================================
# Base class for all widgets bound to a field
# =============================================================================
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnue] r8793 - in trunk/gnue-forms/src: . GFObjects,
reinhard <=