Module Duplex.UIButton
The UIButton is a generic button.
It is very flexible, as you can assign any button type, fader or dial to control it
__________ __________ _______________
| ____ | __ | |
| / __ \ | | | | ____ |
| / / \ \ | | | | | | |
| \ \__/ / | |__| | | // | |
| \/___/ | |__| | |____| |
| | | |
| Dial | Fader | Button |
| | | PushButton |
| | | ToggleButton |
|__________|__________|_______________|
It has no internal "active" or "enabled" state, it merely tells you when an event has occurred. Then, it is up to you to change it's visual state.
Functions
__init (app, map) | Initialize the UIButton class |
do_press (msg) | User pressed button |
do_release (msg) | User released button |
do_change (msg) | User changed value via fader, dial ... |
do_hold (msg) | User held button for a while (exact time is specified in preferences). |
set (val) | method for setting the palette |
flash (delay, ...) | Easy way to animate the appearance of the button |
draw () | Update the appearance - inherited from UIComponent |
add_listeners () |
Add event listeners to the button
|
remove_listeners () | Remove previously attached event listeners |
Tables
palette | (table) the visual appearance, changed via set |
Fields
self.on_change | (func) event handler |
self.on_hold | (func) event handler |
self.on_press | (func) event handler |
self.on_release | (func) event handler |
Functions
- __init (app, map)
-
Initialize the UIButton class
Parameters:
- app (Duplex.Application)
- map [opt] (table) mapping properties
- do_press (msg)
-
User pressed button
Parameters:
- msg (Duplex.Message)
Returns:
-
(bool), true when message was handled
- do_release (msg)
-
User released button
Parameters:
- msg (Duplex.Message)
Returns:
-
(bool), true when message was handled
- do_change (msg)
-
User changed value via fader, dial ...
Parameters:
- msg (Duplex.Message)
Returns:
-
(bool), true when message was handled
- do_hold (msg)
-
User held button for a while (exact time is specified in preferences).
Note that this event is only supported by controllers that transmit the
"release" event
Parameters:
- msg (Duplex.Message)
- set (val)
-
method for setting the palette
Parameters:
- val (table), new color/text values
- flash (delay, ...)
-
Easy way to animate the appearance of the button
Parameters:
- delay (number) number of seconds between updates
- ... (vararg) palette entries
- draw ()
-
Update the appearance - inherited from UIComponent
See also:
- add_listeners ()
-
Add event listeners to the button
DEVICE_EVENT.BUTTON_PRESSED DEVICE_EVENT.BUTTON_RELEASED DEVICE_EVENT.VALUE_CHANGED DEVICE_EVENT.BUTTON_HELD
See also:
- remove_listeners ()
-
Remove previously attached event listeners
See also:
Tables
- palette
-
(table) the visual appearance, changed via set
Fields:
- foreground
(table)
color (table) - {int,int,int} text (string) val (bool)
- foreground