diff --git a/resources/docs/docs/widgets/properties-reference.md b/resources/docs/docs/widgets/properties-reference.md index cd9e9fe6..d8bf4ade 100644 --- a/resources/docs/docs/widgets/properties-reference.md +++ b/resources/docs/docs/widgets/properties-reference.md @@ -714,3 +714,6 @@ |
keyBinding#
| `string`|
`array` | "" | Key combo `string` or `array` of strings (see KeyboardJS documentation) | |
keyRepeat#
| `boolean` | true | Set to `false` to prevent keydown repeats when holding the key combo pressed | |
keyType#
| `string` | "keydown" | Determines which key event trigger the script's execution

Choices: `keydown`, `keyup`, `both` | + +??? api "
variable#
" + Hold a value. diff --git a/src/client/widgets/index.js b/src/client/widgets/index.js index 7a7ab585..c201c795 100644 --- a/src/client/widgets/index.js +++ b/src/client/widgets/index.js @@ -48,6 +48,7 @@ module.exports.widgets = { // scripts script: require('./scripts/script'), + variable: require('./scripts/variable'), } @@ -59,7 +60,7 @@ module.exports.categories = { 'Indicators':['led', 'text'], 'Pads':['xy','rgb','multixy'], 'Sliders':['fader','knob', 'encoder', 'range'], - 'Scripts':['script'], + 'Scripts':['script', 'variable'], } var defaults = {} diff --git a/src/client/widgets/scripts/script.js b/src/client/widgets/scripts/script.js index 8b478cb4..41f9ce5b 100644 --- a/src/client/widgets/scripts/script.js +++ b/src/client/widgets/scripts/script.js @@ -31,7 +31,7 @@ class Script extends Widget { }, [ - 'visible', 'label', 'interaction', + 'visible', 'interaction', '_geometry', 'left', 'top', 'width', 'height', 'expand', '_style', 'colorBg', 'colorText', 'colorWidget', 'colorFill', 'colorStroke', 'alphaStroke', 'alphaFillOn', 'alphaFillOff', 'padding', 'css' diff --git a/src/client/widgets/scripts/variable.js b/src/client/widgets/scripts/variable.js new file mode 100644 index 00000000..c3060a7a --- /dev/null +++ b/src/client/widgets/scripts/variable.js @@ -0,0 +1,41 @@ +var Widget = require('../common/widget'), + StaticProperties = require('../mixins/static_properties') + +module.exports = class Variable extends StaticProperties(Widget, {bypass: true, interaction: false, visible: false}) { + + static description() { + + return 'Hold a value.' + + } + + static defaults() { + + return super.defaults({ + + + }, [ + 'visible', 'interaction', + '_geometry', 'left', 'top', 'width', 'height', 'expand', + '_style', 'colorBg', 'colorText', 'colorWidget', 'colorFill', 'colorStroke', 'alphaStroke', 'alphaFillOn', 'alphaFillOff', 'padding', 'css', + 'decimals', 'bypass' + ], {}) + + } + + constructor(options) { + + super({...options, html: null}) + + } + + + setValue(v, options={}) { + + this.value = v + + if (options.sync) this.changed(options) + + } + +} diff --git a/tests/test.js b/tests/test.js index 10bf719e..924f455d 100644 --- a/tests/test.js +++ b/tests/test.js @@ -16,7 +16,7 @@ var widgets = { 'Indicators':['led', 'text'], 'Pads':['xy','rgb','multixy', 'canvas'], 'Sliders':['fader','knob', 'encoder', 'range'], - 'Scripts':['script'], + 'Scripts':['script', 'variable'], } for (let k in widgets) { for (let type of widgets[k]) {