Buttons are defined as tables, with some values:
image
: the imagestateProvider
: optional state-providing function.imageProvider
will only be called when the state changesimageProvider
: the function returning the image, taking context in a table:isPressed
- whether the button is being pressed downlocation
- table ofx
andy
keys representing the button location- zero-indexed
size
- table ofw
andh
keys representing the deck sizestate
- the state to act on, as returned bystateProvider
onClick
: the function to perform when being clickedonLongPress
: the function to perform when being held down- passed a boolean for if we're being held or released
updateInterval
: the desired update interval (if any) in secondsname
: the name of the buttonchildren
: function returning child buttons, which will be pushed
Internal values:
_lastState
: the last state we heard about for this button_lastImage
: the last image we grabbed for this button_holdTimer
: a timer for long-press events_isHolding
: whether this button is being held down