Class Element

Base class for all elements.

class Element

All products of measure and layout are in device-independent pixels.

Constructors

NameDescription
this () Empty parameter list constructor - for usage by factory

Fields

TypeNameDescription
bool
focusGroup
Signal!(...)
onAnimationEnd
Signal!(...)
onAnimationStart
Signal!(...)
onClick On click event listener
Signal!(...)
onFocusChange Focus state change event listener
Signal!(...)
onKeyEvent Fires on key events, return true to prevent further widget actions
Signal!(...)
onMouseEvent Fires on mouse events, return true to prevent further widget actions
Listener!(...)
onStyleUpdate Signals when styles are being recomputed. Used for mixing properties in the element
Signal!(...)
onWheelEvent Fires on mouse/touchpad scroll events, return true to prevent further widget actions
ushort
tabOrder
Collection!(beamui.widgets.widget.Element,true)
_hiddenChildren

Properties

TypeNameDescription
bool
allowsClick[get, set] True if the element supports click by mouse button or enter/space key
bool
allowsFocus[get, set] True if the element can be focused
bool
allowsHover[get, set] True if the element will change hovered state while mouse pointer is moving upon it
background[set] Set the element background (takes ownership on the object)
const(Boundaries)
boundaries[get] Element boundaries (min, nat, and max sizes).
const(BoxOf!(float))
box[get] Element's rectangle, relative to parent.origin.
bool
canClick[get] True if the element allows click, and it's visible and enabled
bool
canFocus[get] True if the element allows focus, and it's visible and enabled
int
childCount[get] Returns number of children of this element
dependentSize[get] Defines whether element width/height depends on its height/width
const(bool*)
destructionFlag[get] Flag for WeakRef that indicates element destruction
bool
enabled[get] True if the element is interactive.
bool
focused[get] True if this element is currently focused
Ref!(beamui.text.fonts.Font)
font[get] Returns font set for element using style or set manually
bool
hasTooltip[get] Returns true if widget has tooltip to show
string
id[get, set] Widget id, null if not set
const(BoxOf!(float))
innerBox[get] Content box, i.e. box without padding and borders, relative to origin.
SizeOf!(float)
maxSize[get] Maximal size constraint.
SizeOf!(float)
minSize[get] Minimal size constraint.
SizeOf!(float)
natSize[get] Natural (preferred) size.
bool
needDraw[get] Returns true if redraw is required for element and its children
bool
needLayout[get] Returns true if layout is required for element and its children
Vector!(float,2)
origin[get] Global position of box.pos.
overlay[set] Set the element overlay (takes ownership on the object)
InsetsOf!(float)
padding[get] Padding (between background bounds and content of element)
inout(Element)
parent[get, set] Parent element, null for top level element
stateFlags[get, set] Set of widget state flags
style[get] Computed style of this element. Allows to query and mutate its properties
textHotkey[get] Returns computed text hotkey flag: underlineOnAlt is resolved to underline or hidden
dstring
tooltipText[get, set] Tooltip text - when not empty, widget will show tooltips automatically.
visibility[get, set] Widget visibility (visible, hidden, gone)
bool
visible[get] True if this element and all its parents are visible
bool
wantsKeyTracking[get] Override and return true to track key events even when not focused
inout(Window)
window[get] Returns window (if element or its parent is attached to window)
dependentSize[set] Indicate from subclass that element width/height depends on its height/width

Methods

NameDescription
addChild (item) Add a child and return it
applyFlags (flags, set) Set or unset stateFlags (a disjunction of StateFlags options). Returns new state
cancelTimer (timerID) Cancel timer - pass value returned from setTimer() as timerID parameter
child (index) Returns child by index
childByID (id, deepSearch) Find child of specified type T by id, returns null if not found or cannot be converted to type T
childIndex (id) Returns index of element in child list, -1 if there is no child with this ID
childIndex (item) Returns index of element in child list, -1 if passed element is not a child of this element
compareID (id) Compare element id with specified value, returns true if matches
contains (x, y) Returns true if the point (in absolute coordinates) is inside of this element
diffChildren (oldItems)
draw (pr) Draw element at its position
executeInUiThread (runnable) Execute delegate later in UI thread if this widget will be still available.
findFocusableChild (defaultOnly) Search children for first focusable item, returns null if not found
focusGroupElement () Find nearest parent of this widget with focusGroup flag. Returns topmost parent if no focusGroup flag set to any of parents
getAttribute (name) Returns a value of a custom attribute by its name, null if no such attribute.
getCursorType (x, y) Returns mouse cursor type for the element
handleCustomPropertiesChange ()
handleEvent (event) Handle custom event
handleKeyEvent (event) Process key event, return true if event is processed.
handleMouseEvent (event) Process mouse event; return true if event is processed by widget.
handleMoveFocusUsingKeys (event)
handleStyleChange (p) Handle changes of style properties (e.g. invalidate)
handleThemeChange () Handle theme change: e.g. reload some themed resources
handleWheelEvent (event) Process wheel event, return true if the event is processed.
hasAttribute (name) Returns true if the element has a custom attribute of the name
heightForWidth (width) Returns natural height for the given width
insertChild (index, item) Insert child before given index, returns inserted item
invalidate () Request redraw
isChild (item, deepSearch) Returns true if item is child of this element.
layout (geometry) Set element box and lay out element contents.
matchSelector (sel) Match this element with a selector
measure () Measure element - compute minimal, natural and maximal sizes of the border box.
opApply (callback)
opApplyReverse (callback)
removeAllChildren (destroyThem) Remove all children and optionally destroy them
removeAttribute (name) Remove the custom attribute by name from the element. Does nothing if no such attribute.
removeChild (index) Remove child by index, returns removed item
removeChild (id) Remove child by ID, returns removed item
removeChild (child) Remove child, returns removed item
requestActionsUpdate ()
requestLayout () Request relayout of element and its children
selectStyleChain (theme) Get a style chain for this element from theme, least specific styles first
setAttribute (name) Add a custom attribute of the name or change its value if already exists.
setFocus (reason) Set focus to this element or suitable focusable child, returns previously focused element
setOrigin (parentOrigin) Calculate global positions for all elements, participating in layout
setTimer (intervalMillis, handler) Set new timer to call a delegate after specified interval (for recurred notifications, return true from the handler)
widthForHeight (height) Returns natural width for the given height
arrangeContent () Called from layout, after box and innerBox were set
computeBoundaries () ...
drawAllChildren (pr) Just draw all children. Used as default behaviour in some widgets.
drawContent (pr)
handleChildStyleChange (p, v)
handleClick () Called to process click before onClick signal, override to do it
handleFocusChange (focused, receivedFocusFromKeyboard) Called to process focus changes before onFocusChange signal, override to do it