public class UiElementOne node of the user interface.
Remarks
Elements are classes, and that is a deliberate departure from the rest of the engine. An ECS component is a struct because there are a million of them in a hot loop; a UI node has identity, virtual behaviour and event handlers, and there are ten thousand of them. The struct-of-arrays discipline lives where the loops actually are — the layout store and, later, the draw list — and this type is a handle into them.
It holds no geometry and no style of its own. The cascade owns the computed style, the layout tree owns the result, and everything read from here is a lookup into one of the two. That is what keeps a hundred identical list rows from being a hundred copies of anything.
Fields and properties (69)
public AccessibleRole RoleWhat kind of thing this element is, for assistive technology.
public bool IsInAccessibilityTreeWhether this element is a node a screen reader sees.
public string? AccessibleNameWhat this element is called, as a screen reader would say it.
public string? AccessibleDescriptionThe longer sentence a screen reader reads after the name, if there is one.
public string? AccessibleValueWhat this element currently holds, for the kinds of element that hold something.
public AccessibleStates AccessibleStateThe conditions to announce with this element: what it is doing, plus whatever was declared on it.
public AccessibleStates DeclaredAccessibleStateThe bits an application declared on this element itself.
public IReadOnlyList<AccessibleRelationship> AccessibleRelationshipsEvery relation declared on this element, in the order they were added.
protected internal virtual AccessibleRole NativeRoleThe role this kind of element has when nobody says otherwise.
protected internal virtual string? NativeAccessibleNameWhat this kind of element calls itself, from what it already holds.
protected internal virtual string? NativeAccessibleValueWhat this kind of element currently holds, formatted the way it should be said.
protected internal virtual AccessibleStates NativeAccessibleStateThe states this kind of element computes from what it already holds.
public string? CommandScopeThe command scope this element declares, or null if it declares none.
public bool IsCommandTransparentWhether the focus landing here should leave the command route pointing where it was.
public bool IsInCommandTransparentSubtreeWhether this element is inside anything that declares itself command-transparent.
public string? EffectiveCommandScopeThe scope in force here: this element's, or the nearest ancestor's that declares one.
public IEnumerable<string> CommandHandlerIdsThe ids this element handles, in the order they were declared.
public IReadOnlyList<IResponder> RespondersThe responders this element has appended at its own position on the chain.
public IEditableDocument? HostedDocumentThe document this element hosts, if it is the one that hosts it.
public bool AllowDroppublic bool HasInlineStyleWhether anything has been written on this element directly.
public UiDocument DocumentThe document this belongs to.
public bool IsRemovedWhether it has been taken out of its document.
public string TagIts element name, which selectors match on.
public string DeclaredTagThe name this instance's own type answers to, whatever Tag it was given.
protected internal virtual string TagNameThe element name this type answers to when a caller does not choose one.
protected internal virtual UiElement ContentHostWhere content written inside this element's tag actually goes.
public UiElement? ParentIts parent, or null for the root.
public UiSurface? SurfaceRootThe surface this element is the root of, if it is one.
public IReadOnlyList<UiElement> ChildrenIts children, in document order.
public float LineHeightIts line-height in pixels, or NaN for the font's own.
public float LetterSpacingIts letter-spacing in pixels.
public float WordSpacingIts word-spacing in pixels: extra added to every word-separator character.
public float TextIndentIts text-indent in pixels: how far the first line is pushed in.
public FontFeatureSet FontFeaturesThe OpenType features its text is shaped with.
public ParagraphDirection ParagraphDirectionThe base direction its text is laid out at.
public int ZIndexWhere it sits among its siblings when they overlap.
public ComputedStyle StyleWhat the cascade decided. Interned, so two alike elements share one object.
public float FontSizeIts resolved font size in pixels, which every em on it measures against.
public float LeftIts left edge, relative to its parent, after the last layout pass.
public float TopIts top edge, relative to its parent.
public float WidthIts width.
public float HeightIts height.
public string? LanguageWhat language this element's own text is written in, as a BCP-47 tag.
public string ResolvedLanguageThe language in force here: this element's, or the nearest ancestor's, or the document's.
public ElementState StateIts interaction state — hover, focus, active — which selectors match on.
public char AccessKeypublic bool Focusablepublic int TabIndexpublic bool IsFocusScopepublic bool IsFocusedWhether the focus is on it.
public string? Textpublic float OffsetXpublic float OffsetYpublic float AbsoluteLeftIts left edge in document space, after the last layout pass.
public float AbsoluteTopIts top edge in document space.
public Rectangle BoundsWhere it is in document space, after the last layout pass.
public UiTransform? TransformThe affine its rotate and scale paint it under, or null for neither.
public bool IsHitTestVisibleWhether a pointer can land on it. pointer-events: none and visibility: hidden each make it false.
public int IndexInParentWhere this element sits among its siblings, or -1 if it has no parent.
public IUndoManager? UndoManagerThe undo manager this element hosts, if it is one.
public static readonly UiPropertyKey AllowDropPropertyIdentity for AllowDrop.
public static readonly UiPropertyKey AccessKeyPropertyIdentity for AccessKey.
public static readonly UiPropertyKey FocusablePropertyIdentity for Focusable.
public static readonly UiPropertyKey TabIndexPropertyIdentity for TabIndex.
public static readonly UiPropertyKey IsFocusScopePropertyIdentity for IsFocusScope.
public static readonly UiPropertyKey TextPropertyIdentity for Text.
public static readonly UiPropertyKey OffsetXPropertyIdentity for OffsetX.
public static readonly UiPropertyKey OffsetYPropertyIdentity for OffsetY.
Events (1)
public Action<UiElement, UiPropertyKey>? PropertyChangedRaised after any generated UI property changes.
Methods (53)
public void ClearRole()Hands the role back to NativeRole.
public UiElement? AccessibleRelationTarget(AccessibleRelation relation)The first element this one is related to in a given way, if there is one.
public void AddAccessibleRelation(AccessibleRelation relation, UiElement target)Says that this element is related to another one in a way the tree does not show.
public bool RemoveAccessibleRelation(AccessibleRelation relation, UiElement target)Stops saying so.
public int ClearAccessibleRelations(AccessibleRelation relation)Drops every relation of one kind, whatever it pointed at.
protected void InvalidateAccessibility()Tells the document that something a bridge is showing may have changed.
public void Provide<T>(T value) where T : notnullMakes a value available to everything inside this element.
public bool Unprovide<T>()Takes a provided value back off this element.
public bool Provides<T>()Whether this element itself provides one, ignoring its ancestors.
public T? Inject<T>()The nearest provided value of that type, looking up from here.
public bool TryInject<T>(out T? value)The same, told apart from a provided null-shaped default.
public bool RequestClose(UiCloseReason reason = DocumentClosed)Asks whether what this element holds may be closed.
public void AddCommandHandler(string id, Action execute, Func<bool>? canExecute = null, Func<string?>? title = null, Func<bool>? isChecked = null)Declares that this element handles a command.
public bool RemoveCommandHandler(string id)Stops handling a command.
public bool TryGetCommandHandler(string id, out CommandHandler handler)The handler this element declared for a command id, if it declared one.
public void AddResponder(IResponder responder)Appends a responder at this element's position on the chain.
public bool RemoveResponder(IResponder responder)Takes a responder back off.
public IEditableDocument? FindHostedDocument()The nearest document on the way up, or the UI document's, or none.
public void SetStyle(string property, string? value)Writes a declaration onto this element, over anything a stylesheet said.
public void SetStyle(string property, string? value, bool important)The same, for a declaration that carried !important.
public string? GetStyle(string property)Reads back a declaration written with SetStyle.
public void ClearStyle()Takes every inline declaration off this element.
public UiElement()Creates a detached element.
protected internal virtual UiElement? NamedHost(string name)Where content addressed to one of this control's named slots goes.
public UiElement Add(string tag, string? id = null, params ReadOnlySpan<string> classNames)Adds a child element.
public T Add<T>(string? tag = null, string? id = null, params ReadOnlySpan<string> classNames) where T : UiElement, new()Adds a child of a particular element type.
public bool AddClass(string className)Adds a class, and invalidates what that could have changed.
public bool RemoveClass(string className)Removes a class.
public bool HasClass(string className)Whether it carries a class.
public string? Attribute(string name)An attribute's value, if it has one.
public void SetAttribute(string name, string value)Sets an attribute.
public TextLayout? Block()Its text, shaped and wrapped to the width it is being laid out in.
public TextLayout? Block(float width)Its text wrapped to a given width.
public TextLayout? Ellipsized(float contentWidth)Its text as it should be drawn in a box this wide: the same block as Block unless text-overflow: ellipsis is in force and a line does not fit, in which case that line ends in an ellipsis.
protected internal virtual void OnCreated()Builds whatever this element is made of, once, as it joins a document.
protected internal virtual void OnChildAdded(UiElement child)Called on the parent, once a child of it has been created and initialised.
protected internal virtual void OnRemoved()Called once, as the element leaves the document.
protected internal virtual void OnPropertyChanged(UiPropertyKey key)Raised after any generated UI property changes.
protected void RaisePropertyChanged(UiPropertyKey key)Tells the override and the subscribers that a property changed.
protected internal virtual void OnDraw(DrawContext context)Draws whatever this element is, beyond what a stylesheet can describe.
public void AddHandler<T>(Action<UiElement, T> handler, RoutingStrategy strategy = Bubble, bool handledEventsToo = false) where T : UiEventListens for an event on its way through this element.
public bool RemoveHandler<T>(Action<UiElement, T> handler) where T : UiEventStops listening.
public void Raise<T>(T args) where T : UiEventSends an event to this element and along its route.
public void Remove()Takes this element and everything under it out of its document.
public IUndoManager? FindUndoManager()The nearest undo manager on the way up, or the document's, or none.
public void ClearAllowDrop()Unsets AllowDrop, so it takes its default or its ancestor's value again.
public void ClearAccessKey()Unsets AccessKey, so it takes its default or its ancestor's value again.
public void ClearFocusable()Unsets Focusable, so it takes its default or its ancestor's value again.
public void ClearTabIndex()Unsets TabIndex, so it takes its default or its ancestor's value again.
public void ClearIsFocusScope()Unsets IsFocusScope, so it takes its default or its ancestor's value again.
public void ClearText()Unsets Text, so it takes its default or its ancestor's value again.
public void ClearOffsetX()Unsets OffsetX, so it takes its default or its ancestor's value again.
public void ClearOffsetY()Unsets OffsetY, so it takes its default or its ancestor's value again.
Used by (887, showing 40)
- ActionBarMmo.Ui
- BagGridMmo.Ui
- ChatPanelMmo.Ui
- GalleryHelloUi
- HierarchyHelloUi
- HudMmo.Ui
- InspectorHelloUi
- LootRollMmo.Ui
- QuestTrackerMmo.Ui
- ShellHelloUi
- StylesheetTestsMmo.Ui.Tests
- UnitFrameMmo.Ui
- VendorPanelMmo.Ui
- DocumentBenchmarksVixen.Benchmarks.Ui
- EditorShellBenchmarksVixen.Benchmarks.Ui
- EditorShellSceneVixen.Benchmarks.Ui
- AccessKeyTestsVixen.Ui.Tests
- AccessibilityCoverageTestsVixen.Ui.Controls.Advanced.Tests
- AccessibilityCoverageTestsVixen.Ui.Controls.Tests
- AccessibilityNodeVixen.Ui
- AccessibilityNotificationTestsVixen.Ui.Controls.Tests
- AccessibilitySnapshotVixen.Ui.Testing
- AccessibilityTestsVixen.Ui.Tests
- AccessibilityTreeVixen.Ui
- AccessibilityTreeSourceVixen.Ui
- AccessibilityTreeTestsVixen.Ui.Tests
- AccessibilityTreeTestsVixen.Ui.Controls.Tests
- AccessibilityTreeTestsVixen.Ui.Controls.Advanced.Tests
- AccessibleNameLocalisationTestsVixen.Ui.Controls.Tests
- AccessibleNameLocalisationTestsVixen.Ui.Controls.Advanced.Tests
- AccessibleRelationshipVixen.Ui
- AccordionVixen.Ui.Controls
- AdvancedFixtureVixen.Ui.Controls.Advanced.Tests
- AlertVixen.Ui.Controls
- AmbientAcrossDockingTestsVixen.Ui.Controls.Advanced.Tests
- AmbientConsumerVixen.Ui.Controls.Tests
- AmbientProviderVixen.Ui.Controls.Tests
- AmbientValueTestsVixen.Ui.Controls.Tests
- AnimationTestsVixen.Ui.Tests
- ApplicationBarTestsVixen.Ui.Controls.Tests