A scroll pane works like an AnchorPane with scroll bars if the content grows larger than the scroll pane element.

ScrollPane screenshot

Note that scroll panes only use TopLeft anchors for their child elements, every other anchor will be ignored.

See also:

Constructor

new(posX:Int, posY:Int, width:Int, height:Int)

Variables

private@:value(0)clickOffsetBottom:Int = 0

private@:value(0)clickOffsetRight:Int = 0

private@:value(None)clicked:Scrollbar = None

private@:value(0.0)contentHeight:Float = 0.0

private@:value(0.0)contentWidth:Float = 0.0

private@:value(new Array())elements:Array<Element> = new Array()

private@:value(false)isHovered:Bool = false

privatesG:KGraphics

privatescrollTexture:Image

private@:value(0.0)scrollX:FastFloat = 0.0

private@:value(0.0)scrollY:FastFloat = 0.0

private@:value(-1)scrollbarLengthBottom:Int = -1

private@:value(-1)scrollbarLengthRight:Int = -1

private@:value(16)scrollbarWidth:Int = 16

Methods

private_onClick(event:MouseClickEvent):Void

private_onHover(event:MouseHoverEvent):Void

private_onScroll(event:MouseScrollEvent):Void

add(element:Element):Void

Adds an element to the scroll pane.

Parameters:

element

The element

privateinlinecreateNewScrollTexture():Void

privatedrawScrollbars(g:KGraphics):Void

Draws the scrollbars of this pane. Currently, the scrollbars are only drawn outside of the pane.

Parameters:

g

The kha.graphics2.Graphics object for drawing

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

Returns the topmost element at the given position. If no element exists at that position, null is returned.

Parameters:

x

The position's x coordinate

y

The position's y coordinate

Returns:

The element at the given position, this if not found but the the mouse is over the scrollpane or null if the mouse is not over the scrollpane.

privaterecalcElement(element:Element):Void

remove(element:Element):Void

Inherited Variables

Defined by Layout

@:value(false)absorbEvents:Bool = false

If true, this Layout does receive events and block sub-elements from receiving them.

See also:

@:value(TopLeft)defaultAnchor:Anchor = TopLeft

@:value(false)read onlyinvalidLayout:Bool = false

true if the layout needs to be recalculated before the next frame.

@:value(0)paddingBottom:Int = 0

@:value(0)paddingLeft:Int = 0

@:value(0)paddingRight:Int = 0

@:value(0)paddingTop:Int = 0

@:value(false)spreadEvents:Bool = false

If true, all elements of this layout will receive the same events as the layout itself. Individual events are not received then.

This behaviour takes effect only if Layout.absorbEvents is true.

Defined by Element

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

The anchor of this element. Used for the layout.

See also:

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.

private@:value([])children:Array<Element> = []

The children of this element.

private@:value("")read onlyctxElement:String = ""

Current context element

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

privateread onlydrawHeight:Int

The height of this element, used for drawing and event handling.

privateread onlydrawWidth:Int

The width of this element, used for drawing and event handling.

privateread onlydrawX:Int

The x position of this element, used for drawing and event handling.

privateread onlydrawY:Int

The y position of this element, used for drawing and event handling.

private@:value(new Map())eventListeners:Map<String, Array<EventListener<Event>>> = new Map()

@:value(0)height:Int = 0

The height of this element.

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

The layout this element belongs to.

privatelayoutHeight:Int

The height of this element, used for the layout.

privatelayoutWidth:Int

The width of this element, used for the layout.

privatelayoutX:Int

The x position of this element, used for the layout.

privatelayoutY:Int

The y position of this element, used for the layout.

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

private@:value("default")read onlystate:String = "default"

Current context state

private@:value(["" => ["default", "disabled"]])read onlystates:Map<String, Array<String>> = ["" => ["default", "disabled"]]

States for each context element: ctxElement => states

privateread onlystyle:Style

Style of the current context

private@:value(false)styleInitialized:Bool = false

Whether this element already initialized its style.

privateread onlystylesCache:Map<String, Style>

ctxElement!state => 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.

@:value(0)width:Int = 0

The width of this element.

Inherited Methods

Defined by Layout

calcElementSize(element:Element, parentWidth:Int, parentHeight:Int):Bool

Calculates the size of the given element if the size is defined as dynamic by the element's style, taking the dimension of the parent container and the anchor point into account (the container might be a layout or a subsection for example).

Returns:

Bool Whether the element was resized

invalidateLayout():Void

Mark this layout as invalid so that it is recalculated before the next frame is drawn.

privateneedsValidation(element:Element):Bool

inlinesetPadding(left:Int, right:Int, top:Int, bottom:Int):Void

Sets the padding values of this layout.

Parameters:

left

The left padding

right

The right padding

top

The top padding

bottom

The bottom padding

privateset_paddingBottom(bottom:Int):Int

privateset_paddingLeft(left:Int):Int

privateset_paddingRight(right:Int):Int

privateset_paddingTop(top:Int):Int

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

private@:value({ ctxElement : "" })cacheStates(states:Array<String>, ctxElement:String = ""):Void

privatedrawOverlay(g:KGraphics):Void

privateinlinegetAnchorResolved():Anchor

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

privateinlinegetContextState():String

getLayoutOffset():Vector<Int>

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

inlinegetTID():String

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.

privateloadStyle():Void

Sets the style variable to point to the current context.

privateonBuild():Void

privateonResize():Void

inlineremoveChild(child:Element):Void

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

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

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

privateinlinerequireContextElement(ctxElement:String):Void

private@:value({ ctxElement : "" })inlinerequireStates(states:Array<String>, ctxElement:String = ""):Void

privateinlineresetContext():Void

privateinlineresetContextState():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

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.

privateset_height(value:Int):Int

privateinlineset_layout(value:Null<Layout>):Layout

privateset_layoutHeight(value:Int):Int

privateset_layoutWidth(value:Int):Int

privateset_layoutX(value:Int):Int

privateset_layoutY(value:Int):Int

privateset_posX(value:Int):Int

privateset_posY(value:Int):Int

privateset_tID(value:String):String

tID setter. Caches all styles required by this element.

privateset_width(value:Int):Int

toString():String

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