LittleJS 1.31.0

UISystem

UIObject

UI Object - Base level object for all UI elements

Extended by UIButton, UICheckbox, UILayout, UISlider, UIText, UITextInput, UITile, UIVideo

Constructor

new UIObject(pos, size)uiSystem.js:979

Create a UIObject

pos Vector2 optional, default vec2()
size Vector2 optional, default vec2()

Members

Methods

Members

activeColor : Color|undefineduiSystem.js:1006

Color of the object when active, uses hoverColor if undefined

align : 'left'|'center'|'right'uiSystem.js:1097

Horizontal text alignment: left, center, or right

Where on parent (or canvas if no parent) this object is anchored. Components in [-1, 1]: (0,0)=center, (-1,-1)=top-left, (1,1)=bottom-right. Also acts as self-pivot — e.g. (1,-1) puts your top-right corner at the anchor point.

canBeHover : booleanuiSystem.js:1079

True if this can be a hover object

children : Array<UIObject>uiSystem.js:1059

A list of this object's children

Color of the object

cornerRadius : numberuiSystem.js:1026

Corner radius for rounded rects

destroyed : booleanuiSystem.js:1099

Has this object been destroyed?

disabled : booleanuiSystem.js:1013

Is this object disabled?

disabledColor : ColoruiSystem.js:1011

Color when disabled

dragActivate : booleanuiSystem.js:1077

Activate when dragged over with mouse held down

extraTouchSize : numberuiSystem.js:1064

Added size to make small buttons easier to touch on mobile devices

font : stringuiSystem.js:1032

Font for this object

fontStyle : string|undefineduiSystem.js:1035

Font style for this object or undefined

gradientColor : Color|undefineduiSystem.js:1022

Uses a gradient fill combined with color

Color used when hovering over the object

interactive : booleanuiSystem.js:1075

Is this element interactive

Color for line drawing

lineWidth : numberuiSystem.js:1024

Width for line drawing

Position you set: an offset from this object's anchor point (the parent box, or the canvas for roots). This is the input that controls placement — set this, not nativePos.

Resolved position in native UI space, recomputed every frame from localPos + anchor (and nativeHeight, if set). This is a derived output used for drawing and hit-testing; assigning to it has no effect since it is overwritten each frame. Set localPos instead.

navigationAutoSelect : booleanuiSystem.js:1090

Should this be auto selected by navigation? Must also have valid navigation index.

navigationIndex : number|undefineduiSystem.js:1088

Optional navigation order index, lower values are selected first

parent : UIObject|undefineduiSystem.js:1062

This object's parent, position is in parent space

shadowBlur : numberuiSystem.js:1083

Size of shadow blur

shadowColor : ColoruiSystem.js:1081

Color for shadow

Offset of shadow blur

Screen space size of the object

slice : TileSlice|undefineduiSystem.js:1030

Style to draw with in place of the rectangle, tinted by the color for its state; its art has the frame, so the outline, corner radius and shadow are not drawn

soundClick : Sound|undefineduiSystem.js:1073

Sound when interactive element is clicked

soundPress : Sound|undefineduiSystem.js:1067

Sound when interactive element is pressed

soundRelease : Sound|undefineduiSystem.js:1070

Sound when interactive element is released

text : string|undefineduiSystem.js:1009

Text for this ui object

Color for text

textFitScale : numberuiSystem.js:1043

Scale text to fit in the object

textHeight : number|undefineduiSystem.js:1041

Override for text height

textLineColor : ColoruiSystem.js:1051

Color for text line drawing

textLineWidth : numberuiSystem.js:1053

Width for text line drawing

textShadow : Vector2|undefineduiSystem.js:1049

How much to offset the text shadow or undefined. UIText draws it in its shadowColor, which is clear by default, so set that too; the blurred shadow then shows as well unless shadowBlur and shadowOffset are zero. The other widgets draw it in black

textWidth : number|undefineduiSystem.js:1038

Override for text width

visible : booleanuiSystem.js:1055

Should this object be drawn

Methods

addChild(child) → UIObjectuiSystem.js:1107

Add a child UIObject to this object, returns child for chaining

child UIObject
Returns

The child object added

click(playSound)uiSystem.js:1383

Internal function called when object is clicked

playSound boolean optional, default true

Destroy this object, destroy its children, detach its parent, and mark it for removal

getTextPos(textSize) → Vector2uiSystem.js:1321

Get where the text is drawn, the center, or the edge of the text area its align puts it against

textSize Vector2

From getTextSize

getTextSize() → Vector2uiSystem.js:1309

Get the size for text with overrides and scale

isActiveObject() → booleanuiSystem.js:1336

Is the mouse held onto this element

isHoverObject() → booleanuiSystem.js:1332

Is the mouse hovering over this element

isInteractive() → booleanuiSystem.js:1348

Can it be interacted with, it and every parent visible and enabled

isKeyInputObject() → booleanuiSystem.js:1344

Is this object in keyboard input mode

isMouseOverlapping() → booleanuiSystem.js:1154

Check if the mouse is overlapping this ui object

Returns
  • True if overlapping
isNavigationObject() → booleanuiSystem.js:1340

Is the gamepad or keyboard navigation object

navigatePressed()uiSystem.js:1328

Called when the navigation button is pressed on this object

Called when the state of this object changes

Called when user clicks on this object

Called when the mouse enters the object

onKeyDown(e)uiSystem.js:1417

Called with each key while this is the keyInputObject

e KeyboardEvent

Called when the mouse leaves the object

Called when the mouse is pressed while over the object

onRelease()uiSystem.js:1407

Called when a press on it ends, wherever the mouse is let go, or when it is disabled or hidden while held, or an edit takes the press; onClick is the one for a press let go over it

Called each frame before object renders

Called each frame before object updates

removeChild(child)uiSystem.js:1117

Remove a child UIObject from this object

child UIObject

Render the object, called automatically by plugin once each frame

renderDebug(visible)uiSystem.js:1370

Called if uiDebug is enabled

visible boolean optional, default true
toString() → stringuiSystem.js:1352

Returns string containing info about this object for debugging

update() → voiduiSystem.js:1167

Update the object, called automatically by plugin once each frame