Class UiElement¶
Namespace: Apogee.UI
Assembly: Apogee.UI.dll
An element of a document (a div, a text node, a whole document) as scripts hold it. The object is a handle: it names the element without keeping it alive, so one whose element has been destroyed
(its document was closed, an ancestor was destroyed) is
public sealed class UiElement : EngineObject
Inheritance¶
object ← EngineObject ← UiElement
Inherited Members¶
EngineObject.IsAdopted, EngineObject.Handle, EngineObject.IsDestroyed, EngineObject.Class, EngineObject.Adopt(), EngineObject.TryGet(SlotHandle, out EngineObject), EngineObject.Destroy(), object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.ReferenceEquals(object?, object?), object.ToString()
Properties¶
ChildCount¶
The number of elements and text nodes directly inside.
public int ChildCount { get; }
Property Value¶
Class¶
What the registry knows about this object's class.
public override ClassInfo Class { get; }
Property Value¶
ClassName¶
The classes, separated by spaces: what the style rules (.card) match.
public string ClassName { get; set; }
Property Value¶
Document¶
The document the element is in (a document is its own).
public UiElement? Document { get; }
Property Value¶
Id¶
The element's id (the id attribute; ids are unique in a document).
public string Id { get; set; }
Property Value¶
InnerRml¶
The RML of what is inside the element; setting it replaces the children.
public string InnerRml { get; set; }
Property Value¶
IsAlive¶
Whether the element still exists.
public bool IsAlive { get; }
Property Value¶
IsVisible¶
Whether it can be seen: not display: none or visibility: hidden, itself or any element above it.
public bool IsVisible { get; }
Property Value¶
Parent¶
The element it is in, or nothing for a document or an element in no tree.
public UiElement? Parent { get; }
Property Value¶
Tag¶
The tag (div, body), or empty for a dead element.
public string Tag { get; }
Property Value¶
Text¶
The text of a text node (made with
public string Text { get; set; }
Property Value¶
Methods¶
AddStyle(string)¶
Adds style rules (RCSS) to the document this element is in, on top of its own.
public bool AddStyle(string rcss)
Parameters¶
rcss string
Returns¶
Append(UiElement)¶
Puts child, made by
public bool Append(UiElement child)
Parameters¶
child UiElement
Returns¶
Blur()¶
public void Blur()
ById(string)¶
The element with this id in or below this one.
public UiElement? ById(string id)
Parameters¶
id string
Returns¶
Child(int)¶
public UiElement? Child(int index)
Parameters¶
index int
Returns¶
Click()¶
Clicks the element as if the pointer had.
public void Click()
Close()¶
Unloads the document: everything in it is destroyed. Call it on the document.
public void Close()
Closest(string)¶
The nearest element, this one included and going up, that a selector (.card, #menu, div.row) matches.
public UiElement? Closest(string selector)
Parameters¶
selector string
Returns¶
Contains(UiElement)¶
Whether other is this element or inside it.
public bool Contains(UiElement other)
Parameters¶
other UiElement
Returns¶
CreateElement(string)¶
A new element with the tag (div, span, input...) in this element's document, in no tree yet.
public UiElement? CreateElement(string tag)
Parameters¶
tag string
Returns¶
CreateText(string)¶
A new text node in this element's document, in no tree yet.
public UiElement? CreateText(string text)
Parameters¶
text string
Returns¶
DestroyElement()¶
Destroys the element with everything inside it, out of its tree. Every object that names it is dead afterwards.
public void DestroyElement()
Focus()¶
public bool Focus()
Returns¶
GetAttribute(string)¶
public string? GetAttribute(string name)
Parameters¶
name string
Returns¶
HasAttribute(string)¶
public bool HasAttribute(string name)
Parameters¶
name string
Returns¶
HasPseudoClass(string)¶
public bool HasPseudoClass(string name)
Parameters¶
name string
Returns¶
Hide()¶
public void Hide()
InsertBefore(UiElement, UiElement?)¶
The same, before before, a child of this element (or last, when it is nothing).
public bool InsertBefore(UiElement child, UiElement? before = null)
Parameters¶
child UiElement
before UiElement?
Returns¶
Listen(string, ScriptFunction, bool)¶
Calls handler with a click, mousedown, keydown, change, focus...) reaches the element on its way up from
what was hit, or, with capture, on its way down. Returns a number for
public long Listen(string type, ScriptFunction handler, bool capture = false)
Parameters¶
type string
handler ScriptFunction
capture bool
Returns¶
OnDestroyed()¶
protected override void OnDestroyed()
Rect()¶
The element's border box on the screen in pixels, as the last update laid it out: x, y, width, height.
public (float X, float Y, float Width, float Height) Rect()
Returns¶
(float X, float Y, float Width, float Height)
Remove(UiElement)¶
Takes a child out of this element. It is the script's again: put it somewhere else, or let go of it to destroy it.
public bool Remove(UiElement child)
Parameters¶
child UiElement
Returns¶
RemoveAttribute(string)¶
public void RemoveAttribute(string name)
Parameters¶
name string
RemoveProperty(string)¶
public void RemoveProperty(string name)
Parameters¶
name string
ScrollIntoView(bool)¶
public void ScrollIntoView(bool alignWithTop = true)
Parameters¶
alignWithTop bool
SetAttribute(string, string)¶
public void SetAttribute(string name, string value)
Parameters¶
name string
value string
SetProperty(string, string)¶
Sets an inline style (set_property("width", "120px")); false when the name or the value is not valid RCSS.
public bool SetProperty(string name, string value)
Parameters¶
name string
value string
Returns¶
SetPseudoClass(string, bool)¶
public void SetPseudoClass(string name, bool on)
Parameters¶
name string
on bool
Show()¶
Makes the document visible (and it starts to be drawn and to take input).
public void Show()
Unlisten(long)¶
Takes back a listener of this element (the number
public bool Unlisten(long token)
Parameters¶
token long