def cursorLeft(self, pressed: bool) -> None: if not pressed or self.cursor == 0: return self.cursor -= 1 output(self.text[self.cursor])
def deleteCurrent(self, pressed: bool) -> None: if not pressed: return self.text = self.text[: self.cursor] + self.text[(self.cursor + 1) :] output(self.text[self.cursor])
def announce(self) -> None: """ This method is responsible for speaking the announcement when selecting this item. It will only speak the label of the item by default, but it can be overridden to modify this behaviour. """ output(self.label)
def deleteBack(self, pressed: bool) -> None: if not pressed or self.cursor == 0: return output(self.text[self.cursor]) self.text = self.text[: (self.cursor - 1)] + self.text[self.cursor :] self.cursor -= 1
def cursorRight(self, pressed: bool) -> None: if not pressed or self.cursor == len(self.text): return self.cursor += 1 if self.cursor < len(self.text): output(self.text[self.cursor]) else: output("empty")
def receiveText(self, text: str, *args: Any, **kwargs: Any) -> None: self.text = self.text[: self.cursor] + text + self.text[self.cursor :] self.cursor += len(text) output(text)
def announce(self) -> None: output(f"{self.label} {self.text}")