Skip to content

PixelUI.Widget

Base class for all UI widgets. Provides common properties and behavior for positioning, sizing, styling, and event handling.

Properties

NameTypeDescription
appPixelUI.AppThe application instance that owns this widget
parentPixelUI.Frame?The parent frame containing this widget
xintegerX position relative to parent
yintegerY position relative to parent
widthintegerWidth in characters
heightintegerHeight in characters
bgPixelUI.ColorBackground color
fgPixelUI.ColorForeground/text color
_orderIndexinteger?Internal ordering index
visiblebooleanWhether the widget is visible
znumberZ-order for layering (higher values appear on top)
borderPixelUI.NormalizedBorderConfig?Border configuration
idstring?Optional unique identifier
focusablebooleanWhether the widget can receive focus
constraintsPixelUI.NormalizedConstraintConfig?Optional size constraints
drawfun(self:PixelUI.Widget,
handleEventfun(self:PixelUI.Widget,
setFocusedfun(self:PixelUI.Widget,
isFocusedfun(self:PixelUI.Widget):booleanCheck if widget has focus

Methods

_init_base

lua
_init_base()

setSize

lua
setSize()

_applyConstraintLayout

lua
_applyConstraintLayout()

_applySizeConstraints

lua
_applySizeConstraints()

setConstraints

lua
setConstraints()

getConstraints

lua
getConstraints()

setPosition

lua
setPosition(y)

Parameters:

NameTypeDescription
yinteger

setZ

Since: 0.1.0

lua
setZ(z)

Parameters:

NameTypeDescription
znumber

setBorder

Since: 0.1.0

lua
setBorder(borderConfig)

Parameters:

NameTypeDescription
borderConfigPixelUI.BorderConfig|boolean|nil

isFocused

Since: 0.1.0

lua
isFocused()

Returns:

  • boolean

setFocused

Since: 0.1.0

lua
setFocused(focused)

Parameters:

NameTypeDescription
focusedboolean

onFocusChanged

Since: 0.1.0

lua
onFocusChanged(_focused)

Parameters:

NameTypeDescription
_focusedboolean

getAbsoluteRect

Since: 0.1.0

lua
getAbsoluteRect()

Returns:

  • integer - x
  • integer - y
  • integer - width
  • integer - height

containsPoint

lua
containsPoint(px, py)

Parameters:

NameTypeDescription
pxinteger
pyinteger

Returns:

  • boolean

draw

Since: 0.1.0

lua
draw(_textLayer, _pixelLayer)

Parameters:

NameTypeDescription
_textLayerLayer
_pixelLayerLayer

handleEvent

Since: 0.1.0

lua
handleEvent(_event)

Parameters:

NameTypeDescription
_eventstring

Returns:

  • boolean - consumed

Released under the MIT License.