button: add decoupled mode
script: add external option for set()
This commit is contained in:
parent
d208644e39
commit
7cc67e6b59
4 changed files with 21 additions and 3 deletions
|
|
@ -39,9 +39,14 @@ class Button extends Widget {
|
|||
'Interraction mode:',
|
||||
'- `toggle` (classic on/off switch)',
|
||||
'- `push` (press & release)',
|
||||
'- `momentary` (no release, no value sent)',
|
||||
'- `momentary` (no release, no value sent with the address)',
|
||||
'- `tap` (no release, sends `on` as value)'
|
||||
]},
|
||||
decoupled: {type: 'boolean', value: false, help: [
|
||||
'If `true`, the button\'s visual state will not change unless it receives a value that matches `on` or `off` coming from an osc/midi message.',
|
||||
'From a script property this kind of message can be simulated with:',
|
||||
`set('widget_id', value, {external: true})`
|
||||
]},
|
||||
doubleTap: {type: 'boolean', value: false, help: 'Set to `true` to make the button require a double tap to be pushed instead of a single tap'},
|
||||
|
||||
}
|
||||
|
|
@ -197,9 +202,15 @@ class Button extends Widget {
|
|||
if (newstate !== undefined) {
|
||||
|
||||
this.state = newstate
|
||||
if (mode === 'toggle' || mode === 'push') {
|
||||
if (this.getProp('decoupled')) {
|
||||
if (options.fromExternal) {
|
||||
this.container.classList.toggle('on', this.state)
|
||||
}
|
||||
}
|
||||
else if (mode === 'toggle' || mode === 'push') {
|
||||
this.container.classList.toggle('on', this.state)
|
||||
}
|
||||
|
||||
if (mode !== 'momentary') {
|
||||
this.value = this.getProp(this.state ? 'on' : 'off')
|
||||
}
|
||||
|
|
@ -220,6 +231,8 @@ class Button extends Widget {
|
|||
if (mode === 'tap') this.setValue(this.getProp('off'), {sync: false, send: false, tapRelease: true})
|
||||
|
||||
// pulse
|
||||
if (this.getProp('decoupled') && options.fromExternal) return
|
||||
|
||||
clearTimeout(this.pulse)
|
||||
this.container.classList.remove('pulse')
|
||||
setTimeout(()=>{
|
||||
|
|
|
|||
|
|
@ -77,6 +77,7 @@ class ScriptVm extends Vm {
|
|||
if (extraOptions.send === false) options.send = false
|
||||
if (extraOptions.sync === false) options.sync = false
|
||||
if (extraOptions.script === false) options.script = false
|
||||
if (extraOptions.external === true) options.fromExternal = true
|
||||
|
||||
var widgets
|
||||
if (id.includes('*')) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue