def edit(self, button: Button | None = None, index: int = 0) -> None: self.pending_button = button self.pending_index = index # find the completions word = "" self.mask = slip39.word_completion_mask(self.button_sequence) if self.is_input_final(): word = slip39.button_sequence_to_word(self.button_sequence) # modify the input state self.input.edit(self.button_sequence, word, self.pending_button, self.pending_index) # enable or disable key buttons for btn in self.keys: if self.is_input_final(): btn.disable() elif btn is button or self.check_mask(btn.index): btn.enable() else: btn.disable() # invalidate the prompt if we display it next frame if not self.input.text: self.prompt.repaint = True
def edit(self, button: KeyButton = None, index: int = 0): self.pending_button = button self.pending_index = index # find the completions mask = 0 word = "" if _is_final(self.button_sequence): word = slip39.button_sequence_to_word(self.button_sequence) else: mask = slip39.compute_mask(self.button_sequence) # modify the input state self.input.edit(self.button_sequence, word, self.pending_button, self.pending_index) # enable or disable key buttons for btn in self.keys: if (not _is_final(self.button_sequence) and btn is button) or check_mask(mask, btn.index): btn.enable() else: btn.disable() # invalidate the prompt if we display it next frame if not self.input.content: self.prompt.repaint = True