Skip to content

Code Reference

Moritz Tim W. edited this page Nov 7, 2023 · 34 revisions

Nodes

FormContainer: Container

Manages form submission and is intended to contain the form elements.

Properties

submit_button: [Submit]

Calls the submit() function when pressed.

protocol: Protocol

Handles the submission of the form.

Methods

_ready

Connects the submit_button's pressed signal to the submit method if submit_button is not null.

submit

Submits the form data to the protocol.

generate_fields_dict

-> Dictionary Generates a dictionary of the form data.

Parameters:

subject: Node = self The node to generate the dictionary from. This is mainly used for recursion.

is_input

-> bool Returns whether the given node is an input. Inputs are:

  • buttons except MenuButton
  • LineEdit
  • TextEdit
  • ItemList
  • Slider
  • SpinBox
  • GraphEdit

Parameters:

  • subject: Node

ValidatableLineEdit: LineEdit

LineEdit with a [validator].

Properties

validator: [Validator]

Methods

_init

Assigns the style from the [validator] if it exists.

ValidatableTextEdit: TextEdit

TextEdit with a [validator].

Properties

validator: [Validator]

Methods

_init

Assigns the style from the [validator] if it exists.

Resources

Protocol: Resource

Handles form submission and response.

Properties

Methods

submit

-> int Submits form data and returns HTTP status code of the response.

Parameters:

get_value

-> Variant Finds the value of the given Node based on its type.
Throws an error if the type is unknown.

BaseButton -> button_pressed: bool
LineEdit | TextEdit -> text: String
Slider | SpinBox -> value: float
GraphEdit -> get_connection_list(): Array[Dictionary]
ItemList -> items:

Array[{
	selected = is_selected(): bool,
	text = get_item_text(): String,
	icon = get_item_icon(): Texture,
	metadata = get_item_metadata(): Variant
}]

Validator: Resource

Validates Text Input according to rules about length and content.

Properties

REGEX_LIB: Array[String]

A collection of predefined regular expression patterns. Items correspond to the PredefinedRegex

required:= false

Input must have a value. [min_length] will be adjusted if needed.

_prev_min_length:= 0

temporary storage of min_length used by the setter of required

min_length:= 0

Minimum length of the input.

word_range: [Boundaries]

Minimum and Maximum number of matches for \w+ allowed

whitelist: [ListFilter]

List of allowed strings.

blacklist: [ListFilter]

List of prohibited strings.

PredefinedRegex: enum

  1. NONE
  2. ALPHABETICAL
  3. NUMERICAL
  4. ALPHANUMERICAL
  5. EMAIL_ADDRESS
  6. PHONE_NUMBER

predefined := PredefinedRegex.NONE

Predefined pattern to match against.

Behavior: enum

  1. MUST_MATCH_BOTH
    Input must match both the predefined and the custom regex (if both are set)
  2. CAN_MATCH_EITHER
    Input can match either the predefined or the custom regex (if at least one is set)

behavior := Behavior.ALLOW

How predefined and custom regexes are checked against in relation to each other.

custom := ".*"

Custom Pattern to match against.

normalise := false

Normalise the case before matching.

require_single_match := false

Don't allow any more than one match.

Methods

_init

-> void Compiles the custom regex

_on_text_changed

-> void Validates given text and updates valid property.

Parameters:
  • new_text: String New content of the input

validate

-> bool Validates given text against all rules and returns validity

Parameters:
  • subject: String Text to validate

Boundaries: Resource

An upper and lower bound of an integer value.

Properties

min: int

Lower bound

max: int

Upper bound

Methods

has

-> bool Determines if the subject is within the boundaries.

Parameters:
  • subject: int

ListFilter: Resource

A filter with a blacklist or whitelist of strings

Properties

Match: enum

  1. ALL
    All elements must be present
  2. AT_LEAST_ONE
    At least one element must be present

match : Match

Match requirement

elements: Array[String]

The blacklist or whitelist

Methods

is_represented_in

-> bool Returns wether the subject is represented in the list

Parameters:
  • subject: String

size

-> int Returns the output of elements.size()

Clone this wiki locally