UITextInput
Enumerations
- ValidationScenario
Predefined validation scenarios for text input.
- Values:
Standard = 0 - Accepts any input.
Integer = 1 - Accepts only integer input (optional leading minus, digits only).
Decimal = 2 - Accepts decimal numbers (optional leading minus, digits, one dot).
Alphanumeric = 3 - Accepts only alphanumeric characters (letters and digits).
Name = 4 - Accepts names (letters, spaces, apostrophes, hyphens).
Custom = 5 - Uses a custom validation function provided by the user.
Classes
- UITextInput : UIComponent
Note
UIFrame component is automatically added to the node if it is not already present
A text input field component.
Usage example:
def init_text_input() {
get_component(node) $(var textInput : UITextInput?) {
textInput.onChange = @(newText : string) { print("Text changed to {newText}") }
}
}
- ..note::
Input is validated on every change according to the selected scenario.
- Fields:
text : string = “” - The current text in the input field.
placeholder : string = “” - Placeholder text when input is empty and the field is not focused.
maxLength : int = 0 - Maximum length of the input text (0 = unlimited).
onChange : lambda<(value:string):void> - Called when text changes.
validationScenario : ValidationScenario = ui_text_input_component::ValidationScenario.Standard - Validation scenario.
checkFunction : lambda<(text:string;insertPos:int;insertStr:string):string> - Custom validation function (used if scenario is Custom).
textField : UIText ? - The text field component to display the current value.
- UITextInput.on_initialize()
Initializes the text input component and validates initial text.
- UITextInput.on_update()
Handles keyboard input when the component is focused.
- UITextInput.validate_input(text: string; insertPos: int; insertStr: string): string
Validates the input text based on the selected validation scenario.
- Arguments:
text : string
insertPos : int
insertStr : string
- UITextInput.invalidate()
Updates the text field with the current text or placeholder.
Functions
validate_standard (text: string; insertPos: int; insertStr: string) : string
validate_integer (text: string; insertPos: int; insertStr: string) : string
validate_decimal (text: string; insertPos: int; insertStr: string) : string
validate_alphanumeric (text: string; insertPos: int; insertStr: string) : string
validate_name (text: string; insertPos: int; insertStr: string) : string
- validate_standard(text: string; insertPos: int; insertStr: string): string
Accepts any input.
- Arguments:
text : string
insertPos : int
insertStr : string
- validate_integer(text: string; insertPos: int; insertStr: string): string
Accepts only integer input (optional leading minus, digits only).
- Arguments:
text : string
insertPos : int
insertStr : string
- validate_decimal(text: string; insertPos: int; insertStr: string): string
Accepts decimal numbers (optional leading minus, digits, one dot).
- Arguments:
text : string
insertPos : int
insertStr : string
- validate_alphanumeric(text: string; insertPos: int; insertStr: string): string
Accepts only alphanumeric characters (letters and digits).
- Arguments:
text : string
insertPos : int
insertStr : string
- validate_name(text: string; insertPos: int; insertStr: string): string
Accepts names (letters, spaces, apostrophes, hyphens).
- Arguments:
text : string
insertPos : int
insertStr : string