class Element
package koui.elements
extended by Layout, Button, Checkbox, Dropdown, Label, Panel, Progressbar, Slider, TextInput
The base class of all elements.
Static variables
privatestaticinvalidations:Set_koui_elements_Element = new Set()
Set of elements for which to notify their parent layout about a change of position or size on the next frame.
Constructor
Variables
privateautoRenderChildren:Bool = true
Whether the children of the element are automatically drawn after the element, or whether element must render its children by its own. The latter can be useful if the children need to be drawn in a specified order.
disabled:Bool = false
true
if the element is disabled and should not react to events. Also,
elements might look different if disabled depending on the theme.
privateread onlystates:Map<String, Array<String>> = ["" => ["default", "disabled"]]
States for each context element: ctxElement => states
privatetID:String = "_root"
The theme ID of this object. Use this to select which theme settings to apply.
Methods
finaladdEventListener<T>(eventClass:Class<T>, callback:T ‑> Void):Void
Register a callback to be called if the given event occurs on this element.
Example:
var button = new Button("Hello!");
button.addEventListener(MouseClickEvent, (event: MouseClickEvent) -> {
if (event.mouseButton == Left && event.getState() == ClickStart) {
trace("Clicked!");
}
});
Parameters:
eventClass | The class of the event, must be a subclass of |
---|---|
callback | The callback function to call if the event occurs |
privateinlineinvalidateElem():Void
Notify the parent layout on the next frame that this element has changed its size or position. Use the next frame to make sure we don't waste calculations when more than one value changes during one frame.
inlineisAtPosition(x:Int, y:Int):Bool
Return true
if this element overlaps with the given position. Used
internally for event handling most of the time. Elements may override
this method to provide more detailed mouse interaction.
If the element is invisible, false
is returned.
finalinlinelistensTo<T>(eventClass:Class<T>):Bool
Returns whether this element has a registered event listener for the given event type.
finalinlinelistensToUID<T>(eventTypeUID:String):Bool
Returns whether this element has a registered event listener for the given event type.
finalinlinerenderElement(g:KGraphics, element:Element):Void
Setup the given element for drawing and call its draw method afterwards.
privateinlinesetContext(state:String, ctxElement:String = "", recursive:Bool = true):Void
Set the current style context used for drawing. Calling this function is
equivalent to calling setContextState
and setContextElement
. If the
given element name is ""
, the element's tID
is used.
Parameters:
state | |
---|---|
ctxElement |
See also:
setContextElement
setContextState
resetContext
privateinlinesetContextElement(ctxElement:String = ""):Void
Set the drawing context element but keep the current state. If the given
element name is ""
, the element's tID
is used.
See also:
setContextState
setContext
resetContext
privateinlinesetContextState(state:String, recursive:Bool = true):Void
Set the drawing context state but keep the current element.
See also:
setContextElement
setContext
resetContext