RmlElement

Summary

Represents an element in the RmlUi DOM tree, providing DOM-like manipulation, layout inspection, styling, and event handling based on the RmlUi C++ Element API.

Remarks

Danger

All calls made within this class MUST be performed on the Master Thread. See Threads.RunLater on how to safely call this from an asynchronous thread. Failure to comply with this can cause catastrophical failures as the engine is not designed for this.

Definition

Namespace: SDT4.Managed.UI.Rml
Assembly: SDT4.Managed.UI.dll

class RmlElement
Inheritance:

Object ➔ RmlElement

Implements:

IDisposable

Fields

Name Type Description

Properties

Name Type Description
public get; Attributes Object An object representing the declarations of an element’s attribute collection. Returns NamedNodeMap. Attributes are accessed in C# property naming conventions, e.g. margin-left becomes MarginLeft. Return types of the accessed attributes are non-null String.
public get; AttributesTyped NamedNodeMap Gets the strongly typed attribute collection for this element.
public get; Style Object An object representing the declarations of an element’s style attributes. Returns RcssStyleDeclaration. Styles are accessed in C# property naming conventions, e.g. background-color becomes BackgroundColor. Return types of the accessed properties are RmlVariant.
public get; StyleTyped RcssStyleDeclaration Gets an object representing the inline RCSS style declarations of this element.
public get; set; Id String? Gets or sets the unique identifier (id) attribute of the element.
public get; set; ClassName String Gets or sets the class attribute of the element, representing a space-separated list of CSS/RCSS class names.
public get; set; InnerRml String Gets or sets the serialized RML markup contained within the element. Setting this parses the markup and replaces all child nodes.
public get; set; InnerText String? Gets or sets the raw text content of the element if this element is or wraps a text node. Returns if this element cannot be cast to a text element.
public get; set; Value RmlVariant Gets or sets the value of the element. For form controls (inputs, selects, etc.), this interacts with the underlying form control value; otherwise, it accesses the value attribute.
public get; set; OwnerDocument RmlDocument Gets the top-level RmlDocument that contains this element.
public get; PreviousSibling RmlElement Gets the node immediately preceding this element in its parent's child list, or if this element is the first child.
public get; NextSibling RmlElement Gets the node immediately following this element in its parent's child list, or if this element is the last child.
public get; ParentNode RmlElement Gets the parent RmlElement of this element in the DOM tree, or if this element has no parent.
public get; ChildNodes RmlElement[] Gets an array containing all child elements of this element.
public get; FirstChild RmlElement Gets the first direct child element of this node, or if it has no children.
public get; LastChild RmlElement Gets the last direct child element of this node, or if it has no children.
public get; ClassList DomTokenList Gets a live DomTokenList representing the element's class attribute, allowing manipulation of individual classes (add, remove, toggle, contains).
public get; ClientHeight Single Gets the inner height of the element in pixels, including padding but excluding borders, margins, and horizontal scrollbars.
public get; ClientLeft Single Gets the width of the left border of the element in pixels.
public get; ClientTop Single Gets the width of the top border of the element in pixels.
public get; ClientWidth Single Gets the inner width of the element in pixels, including padding but excluding borders, margins, and vertical scrollbars.
public get; OffsetHeight Single Gets the height of the element in pixels, including vertical padding, borders, and scrollbars.
public get; OffsetLeft Single Gets the distance in pixels from the outer left edge of this element to the inner left edge of its RmlElement.OffsetParent.
public get; OffsetTop Single Gets the distance in pixels from the outer top edge of this element to the inner top edge of its RmlElement.OffsetParent.
public get; OffsetWidth Single Gets the width of the element in pixels, including horizontal padding, borders, and scrollbars.
public get; OffsetParent RmlElement Gets the nearest ancestor element that has a position other than static, or if no positioned ancestor exists.

Methods

public Boolean HasAttribute(String name)

Summary: Checks whether the element has an attribute with the given name. Corresponds to JavaScript element.hasAttribute(name).

Parameters:

Returns:


public RmlVariant GetAttribute(String name)

Summary: Retrieves the value of an attribute by its exact case-insensitive name. Corresponds to JavaScript element.getAttribute(name).

Parameters:

Returns:


public Void SetAttribute(String name, RmlVariant value)

Summary: Sets the value of an attribute on the specified element. Corresponds to JavaScript element.setAttribute(name, value).

Parameters:


public Void RemoveAttribute(String name)

Summary: Removes the attribute with the specified name from the element. Corresponds to JavaScript element.removeAttribute(name).

Parameters:


public Void Blur()

Summary: Removes input focus from this element.


public Boolean Focus(Boolean focusVisible)

Summary: Sets input focus to this element.

Parameters:

Returns:


public Void Click()

Summary: Simulates a mouse click on this element, triggering click events and default actions.


public RmlElement? Closest(String selector)

Summary: Traverses this element and its ancestors up toward the document root, returning the first element that matches the specified RCSS selector.

Parameters:

Returns:


public Void DispatchEvent(String type, IReadOnlyDictionary<String?, RmlVariant?>? parameters)

Summary: Dispatches a synthetic event to this node in the DOM tree.

Parameters:


public Void DispatchEvent(RmlEventId type, IReadOnlyDictionary<String?, RmlVariant?>? parameters)

Summary: Dispatches a synthetic event to this node in the DOM tree.

Parameters:


public Void AddEventListener(String type, RmlEventListener listener, Boolean useCapture)

Summary: Registers an event handler for a specific event type on this element by name.

Parameters:


public Void AddEventListener(RmlEventId type, RmlEventListener listener, Boolean useCapture)

Summary: Registers an event handler for a specific event type on this element using an RmlEventId.

Parameters:


public Void RemoveEventListener(String type, RmlEventListener listener, Boolean useCapture)

Summary: Removes a previously registered event listener by event type name.

Parameters:


public Void RemoveEventListener(RmlEventId type, RmlEventListener listener, Boolean useCapture)

Summary: Removes a previously registered event listener by its strongly typed event ID.

Parameters:


public Void AppendChild(RmlElement element)

Summary: Inserts a node as the last child node of this element. The newly parented node must first be detached from its existing parent before being appended.

Parameters:


public RmlElement RemoveChild(RmlElement element)

Summary: Removes a child node from the current element.

Parameters:

Returns:


public RmlElement? GetElementById(String id)

Summary: Returns the descendant element with the specified id attribute.

Parameters:

Returns:


public RmlElement[] GetElementsByClassName(String names)

Summary: Retrieves an array of all descendant elements with the specified class name(s).

Parameters:

Returns:


public RmlElement[] GetElementsByTagName(String name)

Summary: Retrieves an array of all descendant elements with the specified tag/element name.

Parameters:

Returns:


public RmlElement? QuerySelector(String selectors)

Summary: Returns the first descendant element matching the specified RCSS selector string.

Parameters:

Returns:


public RmlElement[] QuerySelectorAll(String selectors)

Summary: Returns an array of all descendant elements matching the specified RCSS selector string.

Parameters:

Returns:


public virtual Boolean Equals(Object? obj)

Summary: Determines whether this instance and another specified object have the same underlying native handle.

Parameters:

Returns:


public virtual Int32 GetHashCode()

Summary: Serves as the default hash function, hashing the underlying native handle.

Returns:


public virtual String ToString()

Summary: Returns a string representation of the element, including its ID, class name, and styles.

Returns:


protected virtual Void Dispose(Boolean disposing)

Summary: Releases unmanaged resources and optionally managed resources.

Parameters:


protected virtual Void Finalize()

Summary: Finalizer for RmlElement that ensures unmanaged handles are cleaned up if owned.


public Void Dispose()

Summary: Releases all resources used by the current instance of RmlElement.

Remarks:

Danger

Do NOT call this on an RmlDocument that is loaded by a context. The result is undefined behaviour