Author: reinhard Date: 2010-07-06 09:10:43 -0500 (Tue, 06 Jul 2010) New Revision: 10193
Modified: trunk/gnue-forms/ trunk/gnue-forms/defaults/default.gfd trunk/gnue-forms/src/GFForm.py trunk/gnue-forms/src/GFObjects/GFTabStop.py trunk/gnue-forms/src/input/displayHandlers/Checkbox.py trunk/gnue-forms/src/input/displayHandlers/Cursor.py Log: Added routines to form to simulate user keypress of character key or backspace keys. Can be used, for example, to add a "numerical keypad" to the toolbar. Nice for touch screen devices. Added possibility to insert form-specific toolbar buttons just before the close button. Property changes on: trunk/gnue-forms ___________________________________________________________________ Name: bzr:revision-info - timestamp: 2010-07-06 10:51:43.145999908 +0200 committer: Reinhard Müller <reinhard.muel...@bytewise.at> properties: branch-nick: forms + timestamp: 2010-07-06 16:08:04.433000088 +0200 committer: Reinhard Müller <reinhard.muel...@bytewise.at> properties: branch-nick: forms Name: bzr:file-ids - src/GFObjects/GFBlock.py 1...@3a364389-8fce-0310-8f11-cc363fde16c7:trunk%2Fgnue-forms:src%2FGFObjects%2FGFBlock.py + defaults/default.gfd 9...@3a364389-8fce-0310-8f11-cc363fde16c7:trunk%2Fgnue-forms:defaults%2Fdefault.gfd src/GFForm.py 6...@3a364389-8fce-0310-8f11-cc363fde16c7:trunk%2Fgnue-forms:src%2FGFForm.py src/GFObjects/GFTabStop.py 3...@3a364389-8fce-0310-8f11-cc363fde16c7:trunk%2Fgnue-forms:src%2FGFObjects%2FGFTabStop.py src/input/displayHandlers/Checkbox.py 7...@3a364389-8fce-0310-8f11-cc363fde16c7:trunk%2Fgnue-forms:src%2Finput%2FdisplayHandlers%2FCheckbox.py src/input/displayHandlers/Cursor.py 7...@3a364389-8fce-0310-8f11-cc363fde16c7:trunk%2Fgnue-forms:src%2Finput%2FdisplayHandlers%2FCursor.py Name: bzr:revision-id:v4 - 3116 reinhard.muel...@bytewise.at-20100426083500-vtmq0qvd7htz02zx 3117 reinhard.muel...@bytewise.at-20100512151744-2jx8tmtop30kl5n0 3118 reinhard.muel...@bytewise.at-20100705094014-ks9yv7b8gs6ychrb 3119 reinhard.muel...@bytewise.at-20100706085143-hyxadj30ayg28jpx + 3116 reinhard.muel...@bytewise.at-20100426083500-vtmq0qvd7htz02zx 3117 reinhard.muel...@bytewise.at-20100512151744-2jx8tmtop30kl5n0 3118 reinhard.muel...@bytewise.at-20100705094014-ks9yv7b8gs6ychrb 3119 reinhard.muel...@bytewise.at-20100706085143-hyxadj30ayg28jpx 3120 reinhard.muel...@bytewise.at-20100706140804-sn3npws1ykm81ubx Name: bzr:text-parents - src/GFObjects/GFBlock.py svn-v3-single1-dHJ1bmsvZ251ZS1mb3Jtcw..:3a364389-8fce-0310-8f11-cc363fde16c7:trunk%2Fgnue-forms:10124 + defaults/default.gfd svn-v3-single1-dHJ1bmsvZ251ZS1mb3Jtcw..:3a364389-8fce-0310-8f11-cc363fde16c7:trunk%2Fgnue-forms:10022 src/GFForm.py svn-v3-single1-dHJ1bmsvZ251ZS1mb3Jtcw..:3a364389-8fce-0310-8f11-cc363fde16c7:trunk%2Fgnue-forms:10130 src/GFObjects/GFTabStop.py svn-v3-single1-dHJ1bmsvZ251ZS1mb3Jtcw..:3a364389-8fce-0310-8f11-cc363fde16c7:trunk%2Fgnue-forms:10108 src/input/displayHandlers/Checkbox.py svn-v3-single1-dHJ1bmsvZ251ZS1mb3Jtcw..:3a364389-8fce-0310-8f11-cc363fde16c7:trunk%2Fgnue-forms:9956 src/input/displayHandlers/Cursor.py svn-v3-single1-dHJ1bmsvZ251ZS1mb3Jtcw..:3a364389-8fce-0310-8f11-cc363fde16c7:trunk%2Fgnue-forms:9956 Modified: trunk/gnue-forms/defaults/default.gfd =================================================================== --- trunk/gnue-forms/defaults/default.gfd 2010-07-06 08:53:14 UTC (rev 10192) +++ trunk/gnue-forms/defaults/default.gfd 2010-07-06 14:10:43 UTC (rev 10193) @@ -260,6 +260,8 @@ <toolbutton name="__sep5__"/> <toolbutton name="__rollback__" action="act__rollback__"/> <toolbutton name="__sep6__"/> + </toolbar> + <toolbar name="__close_toolbar__"> <toolbutton name="__close__" action="act__close__"/> </toolbar> </form> Modified: trunk/gnue-forms/src/GFForm.py =================================================================== --- trunk/gnue-forms/src/GFForm.py 2010-07-06 08:53:14 UTC (rev 10192) +++ trunk/gnue-forms/src/GFForm.py 2010-07-06 14:10:43 UTC (rev 10193) @@ -155,11 +155,13 @@ 'show_about': {'function': self.show_about}, 'show_dialog': {'function': self.show_dialog}, - # Clipboard and selection + # Clipboard, selection, and text entry 'cut': {'function': self.cut}, 'copy': {'function': self.copy}, 'paste': {'function': self.paste}, 'select_all': {'function': self.select_all}, + 'enter_text': {'function': self.enter_text}, + 'backspace': {'function': self.backspace}, # Focus movement 'next_entry': {'function': self.next_entry}, @@ -324,6 +326,19 @@ help_menu.setParent(None) self._children.remove(help_menu) + # Merge extra and exit buttons into the main toolbar. + main_toolbar = self.findChildNamed('__main_toolbar__', 'GFToolbar') + extra_toolbar = self.findChildNamed('__extra_toolbar__', 'GFToolbar') + close_toolbar = self.findChildNamed('__close_toolbar__', 'GFToolbar') + if extra_toolbar: + main_toolbar.merge(extra_toolbar) + extra_toolbar.setParent(None) + self._children.remove(extra_toolbar) + if close_toolbar: + main_toolbar.merge(close_toolbar) + close_toolbar.setParent(None) + self._children.remove(close_toolbar) + self.phaseInit() for subform in self.__subforms.itervalues(): @@ -741,6 +756,28 @@ if isinstance(self._currentEntry, GFFieldBound): self._currentEntry.select_all() + # ------------------------------------------------------------------------- + # Text entry + # ------------------------------------------------------------------------- + + def enter_text(self, text): + """ + Enter text into the current entry as if typed in by the user. + """ + + if isinstance(self._currentEntry, GFFieldBound): + self._currentEntry.enter_text(text) + + # ------------------------------------------------------------------------- + + def backspace(self): + """ + Delete the character left to the cursor in the current entry. + """ + + if isinstance(self._currentEntry, GFFieldBound): + self._currentEntry.backspace() + # ========================================================================= # Focus functions # ========================================================================= Modified: trunk/gnue-forms/src/GFObjects/GFTabStop.py =================================================================== --- trunk/gnue-forms/src/GFObjects/GFTabStop.py 2010-07-06 08:53:14 UTC (rev 10192) +++ trunk/gnue-forms/src/GFObjects/GFTabStop.py 2010-07-06 14:10:43 UTC (rev 10193) @@ -624,7 +624,7 @@ # ------------------------------------------------------------------------- - # Clipboard and selection + # Clipboard, selection, and text entry # ------------------------------------------------------------------------- def cut(self): @@ -654,6 +654,28 @@ self.uiWidget._ui_select_all_(self._visibleIndex) # ------------------------------------------------------------------------- + + def enter_text(self, text): + """ + Add the given text to the entry as if it was typed in by the user. + + This can only used for real texts, it does not process function or + control keys. If the entry currently has an active selection, it is + overwritten. + + @param text: text to add to the entry. + @type text: unicode + """ + + self._displayHandler.enter_text(text) + + # ------------------------------------------------------------------------- + + def backspace(self): + + self._displayHandler.backspace() + + # ------------------------------------------------------------------------- # Refresh the user interface with the current field data for current row # ------------------------------------------------------------------------- Modified: trunk/gnue-forms/src/input/displayHandlers/Checkbox.py =================================================================== --- trunk/gnue-forms/src/input/displayHandlers/Checkbox.py 2010-07-06 08:53:14 UTC (rev 10192) +++ trunk/gnue-forms/src/input/displayHandlers/Checkbox.py 2010-07-06 14:10:43 UTC (rev 10193) @@ -123,12 +123,12 @@ # Correctly handle requestKEYPRESS event - def _addText(self, event): - if event.text == ' ': + def enter_text(self, text): + if text == ' ': self.__toggle () - elif event.text in ['0', '-']: # TODO: add "Y" for current language + elif text in ['0', '-']: # TODO: add "Y" for current language self.__set (False) - elif event.text in ['1', '+']: # TODO: add "N" for current language + elif text in ['1', '+']: # TODO: add "N" for current language self.__set (True) return Modified: trunk/gnue-forms/src/input/displayHandlers/Cursor.py =================================================================== --- trunk/gnue-forms/src/input/displayHandlers/Cursor.py 2010-07-06 08:53:14 UTC (rev 10192) +++ trunk/gnue-forms/src/input/displayHandlers/Cursor.py 2010-07-06 14:10:43 UTC (rev 10193) @@ -185,13 +185,21 @@ return u'' - # ------------------------------------------------------------------------- # Text manipulation # ------------------------------------------------------------------------- def _addText(self, event): + self.enter_text(event.text) + + # ------------------------------------------------------------------------- + + def enter_text(self, text): + """ + Enter a text into the entry. + """ + if self._selection1 is not None: # If text is selected, then we will replace (start, end) = self.getSelectionArea() @@ -199,7 +207,7 @@ # Otherwise just graft the new text in place (start, end) = (self._cursor, self._cursor) - self.__change_text(start, end, event.text, start + len(event.text)) + self.__change_text(start, end, text, start + len(text)) # ------------------------------------------------------------------------- @@ -241,6 +249,12 @@ def _backspace(self, event): + self.backspace() + + # ------------------------------------------------------------------------- + + def backspace(self): + # If there is a selection, delete the selected portion. if self._selection1 is not None: (start, end) = self.getSelectionArea() _______________________________________________ commit-gnue mailing list commit-gnue@gnu.org http://lists.gnu.org/mailman/listinfo/commit-gnue