def _on_submit(dialog: UiDialogTextInput): input_value = CommonDialogUtils.get_input_value(dialog) if not input_value or not dialog.accepted: self.log.debug('Dialog cancelled.') return on_submit(None, CommonChoiceOutcome.CANCEL) self.log.format_with_message( 'Value entered, attempting to convert it to a float.', value=input_value) try: input_value = float(input_value) self.log.debug('Conversion successful.') input_value = max(self.min_value, input_value) input_value = min(self.max_value, input_value) except: self.log.format_with_message('Failed to convert value', value=input_value) return on_submit(None, CommonChoiceOutcome.ERROR) self.log.format_with_message('Value entered.', input_value=input_value) result = on_submit(input_value, CommonChoiceOutcome.CHOICE_MADE) self.log.format_with_message('Finished handling input.', result=result) return result
def _on_submit(dialog: UiDialogTextInput) -> bool: try: input_text = CommonDialogUtils.get_input_value(dialog) if not input_text or not dialog.accepted: self.log.debug('Dialog cancelled.') return on_submit(None, CommonChoiceOutcome.CANCEL) self.log.format_with_message( 'Value entered, attempting to parse it.', value=input_text) input_text = str(input_text) if self.substitute_characters is not None: for (char, replacement) in self.substitute_characters.items(): input_text = input_text.replace(char, replacement) self.log.format_with_message('Value entered.', input_value=input_text) result = on_submit(input_text, CommonChoiceOutcome.CHOICE_MADE) self.log.format_with_message('Finished handling input.', result=result) return result except Exception as ex: self.log.error('Error occurred on submitting a value.', exception=ex) return False
def _on_submit(dialog: UiDialogTextInput) -> None: try: input_value = CommonDialogUtils.get_input_value(dialog) if not input_value or not dialog.accepted: self.log.debug('Dialog cancelled.') on_submit(None, CommonChoiceOutcome.CANCEL) return self.log.format_with_message('Value entered.', input_value=input_value) result = on_submit(input_value, CommonChoiceOutcome.CHOICE_MADE) self.log.format_with_message('Finished handling input.', result=result) except Exception as ex: self.log.error('Error occurred on submitting a value.', exception=ex)