tac.lib.monitor_buttons v1.0.0

Provides reusable button UI components for monitor-based interfaces. Used by server NFC monitor, ShopK access, and other monitor-based UIs.

Author: Twijn
View on GitHub →

Functions

monitor_buttons.create(monitor)

View source

Create a new button manager for a monitor

Parameters:
Returns: table - button manager instance

manager.getSize()

View source

Get monitor dimensions

Returns: number, number - width and height

manager.clearButtons()

View source

Clear all buttons

manager.clear(bgColor)

View source

Clear the monitor

Parameters:

manager.centerText(y, text, color)

View source

Center text on the monitor

Parameters:

manager.drawText(x, y, text, color)

View source

Draw text at position

Parameters:

manager.drawLine(y, char, color)

View source

Draw a horizontal line

Parameters:

manager.drawHeader(y, text, bgColor, textColor)

View source

Draw a header bar

Parameters:

manager.drawButton(x, y, width, height, text, action, bgColor, textColor)

View source

Draw a button and register it

Parameters:
Returns: table - button bounds {x1, y1, x2, y2}

manager.addButton(x, y, width, text, action, bgColor, textColor)

View source

Draw a simple 3-row button (convenience method)

Parameters:
Returns: table - button bounds

manager.isTouchInButton(x, y, button)

View source

Check if a touch is within button bounds

Parameters:
Returns: boolean

manager.setCallback(callback)

View source

Set callback for button presses

Parameters:

manager.setTimeout(seconds, callback)

View source

Set a timeout for the current screen

Parameters:

manager.handleTouch(x, y)

View source

Handle a touch event

Parameters:
Returns: string|nil - action if button was pressed, nil otherwise

manager.handleTimer(timerID)

View source

Handle a timer event

Parameters:
Returns: boolean - true if this was our timeout timer

manager.showCountdown(y, prefix, seconds)

View source

Show a countdown timer on the monitor

Parameters:

manager.showSuccess(title, message, details)

View source

Show a success screen

Parameters:

manager.showError(title, message)

View source

Show an error screen

Parameters:

manager.hasActiveButtons()

View source

Check if there are active buttons

Returns: boolean