commit-gnue
[Top][All Lists]
Advanced

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

[gnue] r8715 - in trunk/gnue-forms/src: . GFObjects uidrivers/_base uidr


From: reinhard
Subject: [gnue] r8715 - in trunk/gnue-forms/src: . GFObjects uidrivers/_base uidrivers/_base/widgets
Date: Thu, 5 Oct 2006 10:47:12 -0500 (CDT)

Author: reinhard
Date: 2006-10-05 10:47:11 -0500 (Thu, 05 Oct 2006)
New Revision: 8715

Modified:
   trunk/gnue-forms/src/GFForm.py
   trunk/gnue-forms/src/GFInstance.py
   trunk/gnue-forms/src/GFObjects/GFBlock.py
   trunk/gnue-forms/src/uidrivers/_base/UIdriver.py
   trunk/gnue-forms/src/uidrivers/_base/widgets/_base.py
Log:
Introduced new GFForm.adjust_ui_focus that causes the UI focus to follow the GF
focus.


Modified: trunk/gnue-forms/src/GFForm.py
===================================================================
--- trunk/gnue-forms/src/GFForm.py      2006-10-05 14:11:26 UTC (rev 8714)
+++ trunk/gnue-forms/src/GFForm.py      2006-10-05 15:47:11 UTC (rev 8715)
@@ -90,6 +90,10 @@
         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
@@ -290,8 +294,7 @@
         self.update_status()
 
         assert gDebug(4, "Setting initial focus")    
-        self.dispatchEvent('gotoENTRY', object = self._currentEntry,
-                _form = self)
+        self.adjust_ui_focus()
         self.beginEditing()
 
         self.__visible = True
@@ -415,7 +418,7 @@
           raise "setFocus failed: Can just switch to GFEntry objects. " +\
                 "You passed a '%s' object." % focus._type
         self.changeFocus(focus)
-        self.dispatchEvent('gotoENTRY', object=self._currentEntry, _form=self)
+        self.adjust_ui_focus()
         self._in_trigger_lock = False
 
     # -------------------------------------------------------------------------
@@ -718,7 +721,7 @@
             # Set focus on GF layer
             self.changeFocus(entry)
             # Set focus on UI layer
-            self.dispatchEvent('gotoENTRY', object=entry, _form=self)
+            self.adjust_ui_focus()
 
 
     # -------------------------------------------------------------------------
@@ -888,6 +891,42 @@
 
 
     # -------------------------------------------------------------------------
+    # 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.
+        """
+
+        # FIXME: All these should be removed
+        if self._currentEntry is None:
+            print "adjust_ui_focus without current entry"
+            return
+
+        if self._currentEntry == self.__last_focus_object \
+                and self._currentEntry._visibleIndex == 
self.__last_focus_index:
+            print "adjust_ui_focus wouldn't be needed"
+            return
+
+        if self._currentEntry.uiWidget is None:
+            print "adjust_ui_focus called without uiWidget"
+            return
+
+        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)
+        self.__last_focus_object = self._currentEntry
+        self.__last_focus_index = self._currentEntry._visibleIndex
+
+
+    # -------------------------------------------------------------------------
     # Info about focus position
     # -------------------------------------------------------------------------
 
@@ -1103,7 +1142,7 @@
         self.status_message(u_('Enter your query criteria.'))
 
         self.refreshDisplay(self)
-        self.dispatchEvent('gotoENTRY', object=self._currentEntry, _form=self)
+        self.adjust_ui_focus()
         self.beginEditing()
         self.update_status()
 
@@ -1134,7 +1173,7 @@
         self.status_message(u_('Enter your query criteria.'))
 
         self.refreshDisplay(self)
-        self.dispatchEvent('gotoENTRY', object=self._currentEntry, _form=self)
+        self.adjust_ui_focus()
         self.beginEditing()
         self.update_status()
 
@@ -1155,7 +1194,7 @@
         self.status_message(u_('Query canceled.'))
 
         self.refreshDisplay(self)
-        self.dispatchEvent('gotoENTRY', object=self._currentEntry, _form=self)
+        self.adjust_ui_focus()
         self.beginEditing()
         self.update_status()
 
@@ -1192,8 +1231,7 @@
             else:
                 self.status_message (u_('Query successful.'))
 
-            self.dispatchEvent('gotoENTRY', object=self._currentEntry,
-                    _form=self)
+            self.adjust_ui_focus()
             self.beginEditing()
             self.update_record_counter()
             self.update_record_status()
@@ -1217,8 +1255,7 @@
             self.refreshDisplay(self)
             self.update_record_counter()
             self.update_record_status()
-            self.dispatchEvent('gotoENTRY', object=self._currentEntry,
-                    _form=self)
+            self.adjust_ui_focus()
             self.beginEditing()
 
     # -------------------------------------------------------------------------
@@ -1296,7 +1333,7 @@
         self.refreshDisplay(self)
         self.update_record_counter()
         self.update_record_status()
-        self.dispatchEvent ('gotoENTRY', object=self._currentEntry, _form=self)
+        self.adjust_ui_focus()
         self.beginEditing()
 
     # -------------------------------------------------------------------------

Modified: trunk/gnue-forms/src/GFInstance.py
===================================================================
--- trunk/gnue-forms/src/GFInstance.py  2006-10-05 14:11:26 UTC (rev 8714)
+++ trunk/gnue-forms/src/GFInstance.py  2006-10-05 15:47:11 UTC (rev 8715)
@@ -446,8 +446,7 @@
     except:
       # Old focus entry has invalid value: beat the UI focus back, so we are
       # captured until the value is corrected.
-      self.dispatchEvent ('gotoENTRY', object = event._form._currentEntry,
-                         _form = event._form)
+      event._form.adjust_ui_focus()
       raise
 
     if event.data._type in ['GFEntry', 'GFImage', 'GFButton']:
@@ -456,8 +455,7 @@
 
       event._form.changeFocus(event.data)
 
-      self.dispatchEvent ('gotoENTRY', object = event._form._currentEntry,
-                         _form = event._form)
+      event._form.adjust_ui_focus()
       event._form.beginEditing()
 
       event._form.update_record_status()
@@ -486,10 +484,8 @@
 
     # If the trigger changed focus, no need in us doing it too...
     if origEntry == event._form._currentEntry:
-      event._form.nextEntry ()
-
-      self.dispatchEvent ('gotoENTRY', object = event._form._currentEntry,
-                          _form = event._form)
+      event._form.nextEntry()
+      event._form.adjust_ui_focus()
       event._form.beginEditing()
 
     event._form.update_record_status()
@@ -516,9 +512,8 @@
 
     # If the trigger changed focus, no need in us doing it too...
     if origEntry == event._form._currentEntry:
-      event._form.previousEntry ()
-      self.dispatchEvent ('gotoENTRY', object = event._form._currentEntry,
-                          _form = event._form)
+      event._form.previousEntry()
+      event._form.adjust_ui_focus()
       event._form.beginEditing()
 
     event._form.update_record_status()

Modified: trunk/gnue-forms/src/GFObjects/GFBlock.py
===================================================================
--- trunk/gnue-forms/src/GFObjects/GFBlock.py   2006-10-05 14:11:26 UTC (rev 
8714)
+++ trunk/gnue-forms/src/GFObjects/GFBlock.py   2006-10-05 15:47:11 UTC (rev 
8715)
@@ -366,8 +366,7 @@
             # Now we must jump to the new current widget in the UI
             entry = self._form._currentEntry
             if getattr(entry, '_block', None) == self:
-                self._form.dispatchEvent('gotoENTRY', object=entry,
-                        _form=self._form)
+                self._form.adjust_ui_focus()
                 # We are still in editing mode, so we have to update the entry
                 # editor
                 if hasattr(entry, '_displayHandler'):
@@ -423,8 +422,7 @@
     else:
       # If we didn't move the cursor, we have to update cursor position in UI
       if getattr(self._form._currentEntry, '_block', None) == self:
-        self._form.dispatchEvent('gotoENTRY',
-                object=self._form._currentEntry, _form=self._form)
+          self._form.adjust_ui_focus()
 
 
   # ---------------------------------------------------------------------------
@@ -649,8 +647,7 @@
 
         self.__focus_in()
 
-        self._form.dispatchEvent('gotoENTRY',
-                object=self._form._currentEntry, _form=self._form)
+        self._form.adjust_ui_focus()
 
         self._form.beginEditing()
 
@@ -677,8 +674,7 @@
 
         self.__focus_in()
 
-        self._form.dispatchEvent('gotoENTRY',
-                object=self._form._currentEntry, _form=self._form)
+        self._form.adjust_ui_focus()
 
         self._form.beginEditing()
 
@@ -710,8 +706,7 @@
 
         self.__focus_in()
 
-        self._form.dispatchEvent('gotoENTRY',
-                object=self._form._currentEntry, _form=self._form)
+        self._form.adjust_ui_focus()
 
         self._form.beginEditing()
 
@@ -738,8 +733,7 @@
 
         self.__focus_in()
 
-        self._form.dispatchEvent('gotoENTRY',
-                object=self._form._currentEntry, _form=self._form)
+        self._form.adjust_ui_focus()
 
         self._form.beginEditing()
 
@@ -776,8 +770,7 @@
 
         self.__focus_in()
 
-        self._form.dispatchEvent('gotoENTRY',
-                object=self._form._currentEntry, _form=self._form)
+        self._form.adjust_ui_focus()
 
         self._form.beginEditing()
 
@@ -821,8 +814,7 @@
 
         self.__focus_in()
 
-        self._form.dispatchEvent('gotoENTRY', object=self._form._currentEntry,
-                _form=self._form)
+        self._form.adjust_ui_focus()
 
         self._form.beginEditing()
 
@@ -851,8 +843,7 @@
 
         self.__focus_in()
 
-        self._form.dispatchEvent('gotoENTRY', object=self._form._currentEntry,
-                _form=self._form)
+        self._form.adjust_ui_focus()
 
         self._form.beginEditing()
 

Modified: trunk/gnue-forms/src/uidrivers/_base/UIdriver.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/_base/UIdriver.py    2006-10-05 14:11:26 UTC 
(rev 8714)
+++ trunk/gnue-forms/src/uidrivers/_base/UIdriver.py    2006-10-05 15:47:11 UTC 
(rev 8715)
@@ -162,8 +162,6 @@
                    % (uiDriver, widgetName))
         assert gDebug (1, ' --> %s' % mesg)
 
-    self._uiFocusWidget = None
-
     # Dialogs required by base
     #
     # TODO: Once <dialog> works we may be able to do away with these
@@ -184,7 +182,6 @@
 
     # register incomming events
     self.registerEventListeners ({
-            'gotoENTRY'        : self.switchFocus,
             'updateENTRY'      : self.updateEntry,
             'updateEntryEditor': self.updateEntryEditor,
             'gotoPAGE'         : self.goto_page,
@@ -322,24 +319,7 @@
   # execute the actions.  These events come from the forms back end.
   #
 
-
   # ---------------------------------------------------------------------------
-  # Moves the focus to a specific UI widget
-  # ---------------------------------------------------------------------------
-
-  def switchFocus (self, event):
-
-    object = event.object
-    if object: # Some pages might not have any widgets that can be active
-      if self._uiFocusWidget:
-          index = self._uiFocusIndex
-          self._uiFocusWidget.lose_focus (index)
-      self._uiFocusWidget = self._gfObjToUIWidget [object]
-      self._uiFocusIndex = object._visibleIndex
-      self._uiFocusWidget.indexed_focus (object._visibleIndex)
-
-
-  # ---------------------------------------------------------------------------
   # Update all visible toolkit widgets tied to a specific GFObject
   # ---------------------------------------------------------------------------
 

Modified: trunk/gnue-forms/src/uidrivers/_base/widgets/_base.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/_base/widgets/_base.py       2006-10-05 
14:11:26 UTC (rev 8714)
+++ trunk/gnue-forms/src/uidrivers/_base/widgets/_base.py       2006-10-05 
15:47:11 UTC (rev 8715)
@@ -214,6 +214,12 @@
     def create_widget(self, event, spacer):
         assert gDebug(1,"UI doesn't support %s" % self.__class__)
 
+    def _ui_set_focus_(self, index):
+        self.indexed_focus(index)
+
+    def _ui_lose_focus_(self, index):
+        self.lose_focus(index)
+
     def indexed_focus(self, index):
         pass
 





reply via email to

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