def typeText(self, string): """ Type the given text into the node, with appropriate delays and logging. """ logger.log("Typing text into %s: '%s'" % (self.getLogString(), string)) if self.focusable: if not self.focused: try: self.grabFocus() except Exception: logger.log("Node is focusable but I can't grabFocus!") rawinput.typeText(string) else: logger.log("Node is not focusable; falling back to inserting text") et = self.queryEditableText() et.insertText(self.caretOffset, string, len(string)) self.caretOffset += len(string) doDelay()
def type(text): if focus.widget.node: focus.widget.node.typeText(text) else: rawinput.typeText(text)