Displays a progress bar.

Progressbar screenshot

// Construct a new Progressbar with a value range of [0, 200].
var myProgressbar = new Progressbar(0, 200);

// Display the percentage of progress
myProgressbar.label = "Progress: ::percentage::%"

// Set the value to 36, which is 18% of the value range
myProgressbar.value = 36;

Constructor

@:value({ maxValue : 1.0, minValue : 0.0 })new(minValue:FastFloat = 0.0, maxValue:FastFloat = 1.0)

Create a new Progressbar with the given value range.

Variables

@:value(1.0)maxValue:FastFloat = 1.0

The largest possible value of this progress bar.

@:value(0.0)minValue:FastFloat = 0.0

The smallest possible value of this progress bar.

@:value(0)precision:Int = 0

The amount of decimal places of the value of this progress bar. Used only for displaying the label. The value itself is not changed by this variable. If you need to change the value to this precision, use MathUtil.roundPrecision().

See also:

@:value(0.0)read onlyprogress:FastFloat = 0.0

The current progress (in the interval [0, 1]).

@:value("")text:String = ""

The label of this progress bar.

Tip: Use Haxe's template system with ::value::, ::progress::, ::percentage:: (progress * 100 as integer value), ::minValue:: or ::maxValue::! Other template variables are not supported.

myProgressbar.label = "Progress: ::percentage::%";

See also:

@:value(0.0)value:FastFloat = 0.0

The current value (in the interval [minValue, maxValue]).

Methods

Inherited Variables

Defined by Element

@:value(Anchor.FollowLayout)anchor:Anchor = Anchor.FollowLayout

The anchor of this element. Used for the layout.

See also:

@: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.

@:value(0)height:Int = 0

The height of this element.

@:value(null)layout:Null<Layout> = null

The layout this element belongs to.

@:value(null)read onlyparent:Null<Element> = null

The parent element of this element.

@:value(0)posX:Int = 0

The x position of this element.

@:value(0)posY:Int = 0

The y position of this element.

@:value(true)visible:Bool = true

If false, the element is not visible and will not react to any events.

@:value(0)width:Int = 0

The width of this element.

Inherited Methods

Defined by Element

inlineaddChild(child:Element):Void

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 koui.events.Event

callback

The callback function to call if the event occurs

getChild<T>(matchBehaviour:ElementMatchBehaviour):Null<T>

getElementAtPosition(x:Int, y:Int):Null<Element>

getLayoutOffset():Vector<Int>

Return the offset of the element's position to the screen.

inlinegetTID():String

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.

inlineremoveChild(child:Element):Void

finalinlinerenderElement(g:KGraphics, element:Element):Void

Setup the given element for drawing and call its draw method afterwards.

inlinesetPosition(posX:Int, posY:Int):Void

Set the position of this element. You can also change the position per axis, see posX and posY.

inlinesetSize(width:Int, height:Int):Void

Set the size of this element. You can also change the size for each individual side, see width and height.

setTID(tID:String):Void

Set the theme ID of this element.

toString():String

Return a string representation of this element: "Element: <[ClassName]>"