RMLElement

A reference to a element in a RMLDocument document.

Description

This class references a element inside a document and allows direct modification to class names, id, attributes and style properties, as well adding and removing childs.

Methods

void

add_event_listener(name: String, listener: Callable

void

append_child(child: RMLElement

void

clear_children() 

Variant

get_attribute(name: String, default_value: Variantconst

RMLElement

get_child(index: intconst

int

get_child_count() const

RMLElement[]

get_children() const

String

get_class_names() const

String

get_id() const

String

get_inner_rml() const

RMLElement

get_parent() const

String

get_property(name: String, default_value: Stringconst

Rect2

get_rect() const

String

get_tag_name() const

PackedStringArray

get_text_content() const

bool

has_class(name: Stringconst

bool

is_valid() const

RMLElement

query_selector(selector: Stringconst

RMLElement[]

query_selector_all(selector: Stringconst

void

remove_attribute(name: String

void

remove_child(child: RMLElement

void

remove_class(name: String

void

remove_event_listener(name: String, listener: Callable

void

remove_property(name: String

void

set_attribute(name: String, value: Variant

void

set_class(name: String

void

set_class_names(names: String

void

set_id(id: String

void

set_inner_rml(rml: String

void

set_property(name: String, value: String

void

set_text_content(text: String

void

toggle_class(name: String

Method Descriptions

void add_event_listener(name: String, listener: Callable)

Listens to the element event with name event_id.
listener is called with a Dictionary with the information about the event along with the following keys:
type: The type of the event, is equal to event_id;
target_element: The target element which first triggered the event;
current_element: Current element which receives the event;
Along with the event information, you can stop propagation of the event adding the key stop_propagation or stop_immediate_propagation to true.

void append_child(child: RMLElement)

Appends child as a child of this element.

void clear_children()

Clears all the children of this element.

Variant get_attribute(name: String, default_value: Variant) const

Gets the attribute name, if the element doesn't have this attribute, returns default_value.

RMLElement get_child(index: int) const

Returns the child at index.

int get_child_count() const

Returns the number of children this element have.

RMLElement[] get_children() const

Returns the list of children of this element.

String get_class_names() const

Returns the list of class names of this element.

String get_id() const

Gets the ID of this element.

String get_inner_rml() const

Returns the inner RML of this element.

RMLElement get_parent() const

Returns the parent of this element.

String get_property(name: String, default_value: String) const

Gets the style property name, if the element doesn't have this property, returns default_value.

Rect2 get_rect() const

Returns the bounding rectangle of this element in document space.

String get_tag_name() const

Gets the tag name of this element.

PackedStringArray get_text_content() const

Returns a list of text from text nodes as direct or indirect child.

bool has_class(name: String) const

Returns true if this element has class.

bool is_valid() const

Returns true when this RMLElement references a valid element.
Note: The methods on this class never returns an null RMLElement, but the object can reference a null element in RmlUi.
In this case, if the GDExtension is built with element_reference_strict=no flag which is the default, the methods does nothing and/or returns default values.
Enabling the flag throws errors on runtime when trying to manipulate a invalid reference.

RMLElement query_selector(selector: String) const

Selects the first direct or indirect child of this element which matches selector.

RMLElement[] query_selector_all(selector: String) const

Selects all direct and indirect childs of this element which matches selector.

void remove_attribute(name: String)

Removes attribute name from the element.

void remove_child(child: RMLElement)

Removes child as a child of this element.

void remove_class(name: String)

Toggles class from the list of class names of this element.

void remove_event_listener(name: String, listener: Callable)

Removes the listener as a listener of the event with name event_id.

void remove_property(name: String)

Removes style property name from the element.

void set_attribute(name: String, value: Variant)

Sets attribute name to value.

void set_class(name: String)

Adds class in the list of class names of this element.

void set_class_names(names: String)

Sets the list of class names of this element to class_names.

void set_id(id: String)

Sets the ID of this element to id.

void set_inner_rml(rml: String)

Sets the inner RML of this element, clears all it's children and replaces then with new elements based on rml.

void set_property(name: String, value: String)

Sets style property name to value.

void set_text_content(text: String)

Sets the text content of this element, clears all it's children and replaces then with a single text element with text as it's content.

void toggle_class(name: String)

Toggles class in the list of class names of this element.