Пример #1
0
    def set_focus (self, focus=True):
        """E.set_focus (...) -> bool
        
        Sets the input and action focus of the Editable.
        
        Sets the input and action focus of the Editable and returns True
        upon success or False, if the focus could not be set.

        Note: This method only works as supposed using
        a render loop, which supports the Renderer class specification.
        """
        if not self.sensitive:
            return False
        
        BaseWidget.set_focus (self, focus)
        if focus:
            # Save the text after activation and reset the caret blink
            # effects.
            self._caret_visible = True
            self._temp = self.text
            self._caret_visible = True
            self._counter = 0
            self.state = STATE_ACTIVE
        elif self._temp != self.text:
            # If the Editable looses its input focus _and_ has changed text,
            # it will be validated by default.
            if base.debug: print "Editable.INPUT"
            self._temp = self.text
            self.state = STATE_NORMAL
            self.run_signal_handlers (SIG_INPUT)
        else:
            # The Editable looses its input focus without any change.
            self.state = STATE_NORMAL
            self._caret = 0
        return True
Пример #2
0
    def set_focus(self, focus=True):
        """E.set_focus (...) -> bool
        
        Sets the input and action focus of the Editable.
        
        Sets the input and action focus of the Editable and returns True
        upon success or False, if the focus could not be set.

        Note: This method only works as supposed using
        a render loop, which supports the Renderer class specification.
        """
        if not self.sensitive:
            return False

        if focus:
            # Save the text after activation and reset the caret blink
            # effects.
            self._set_caret_visible(True)
            self._temp = self.text
            self._caretvisible = True
            self._timer = _TIMER
            self.state = STATE_ACTIVE
        elif self._temp != self.text:
            # If the Editable looses its input focus _and_ has changed text,
            # it will be validated by default.
            self._temp = self.text
            self.state = STATE_NORMAL
            self.run_signal_handlers(SIG_INPUT)
        else:
            # The Editable looses its input focus without any change.
            self.state = STATE_NORMAL
        BaseWidget.set_focus(self, focus)
        return True