class Label
package koui.elements
extends Element
A simple label that displays text.
Constructor
Variables
@:value(HorTextAlignment.TextLeft)alignmentHor:HorTextAlignment = HorTextAlignment.TextLeft
Horizontal alignment of the text.
@:value(VerTextAlignment.TextTop)alignmentVert:VerTextAlignment = VerTextAlignment.TextTop
Vertical alignment of the text.
Methods
Inherited Variables
Defined by Element
private@:value(true)autoRenderChildren: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.
@:value(false)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.
private@:value(["" => ["default", "disabled"]])read onlystates:Map<String, Array<String>> = ["" => ["default", "disabled"]]
States for each context element: ctxElement => states
private@:value(false)styleInitialized:Bool = false
Whether this element already initialized its style.
private@:value("_root")tID:String = "_root"
The theme ID of this object. Use this to select which theme settings to apply.
@:value(true)visible:Bool = true
If false
, the element is not visible and will not react to any events.
Inherited Methods
Defined by Element
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.
private@:value({ ctxElement : "" })inlinerequireStates(states:Array<String>, ctxElement:String = ""):Void
private@:value({ recursive : true, ctxElement : "" })inlinesetContext(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
private@:value({ ctxElement : "" })inlinesetContextElement(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
private@:value({ recursive : true })inlinesetContextState(state:String, recursive:Bool = true):Void
Set the drawing context state but keep the current element.
See also:
setContextElement
setContext
resetContext