Author: johannes Date: 2005-04-27 03:33:55 -0500 (Wed, 27 Apr 2005) New Revision: 7491
Modified: trunk/gnue-forms/src/uidrivers/curses/widgets/entry.py Log: Don't get out of bounds if a field has no maxLength Modified: trunk/gnue-forms/src/uidrivers/curses/widgets/entry.py =================================================================== --- trunk/gnue-forms/src/uidrivers/curses/widgets/entry.py 2005-04-26 20:04:07 UTC (rev 7490) +++ trunk/gnue-forms/src/uidrivers/curses/widgets/entry.py 2005-04-27 08:33:55 UTC (rev 7491) @@ -42,6 +42,9 @@ self.__style = event.object.style if self.__style in ['default', 'password', 'label', 'dropdown', 'listbox']: self.__length = event.object ['Char:width'] + else: + self.__length = None + self.__value = {} self.__selection = {} self.__enabled = {} @@ -95,7 +98,18 @@ if self.__style != 'checkbox': self._setCursor (position, 0) + # --------------------------------------------------------------------------- + # Move the cursor up to the maximum entry width, but not any further ! + # --------------------------------------------------------------------------- + + def _setCursor (self, x, y): + + if self.__length and x <= self.__length: + UIHelper._setCursor (self, x, y) + + + # --------------------------------------------------------------------------- # Set start and end of selection area # --------------------------------------------------------------------------- @@ -119,10 +133,12 @@ if self.__style in ['default', 'label', 'dropdown', 'listbox']: text = value or '' text += ' ' * (self.__length - len (text)) + text = text [-self.__length:] elif self.__style == 'password': text = '*' * len (value or '') text += ' ' * (self.__length - len (text)) + text = text [-self.__length:] elif self.__style == 'checkbox': if self.__value [index]: _______________________________________________ Commit-gnue mailing list Commit-gnue@gnu.org http://lists.gnu.org/mailman/listinfo/commit-gnue