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
|
|
@ -2,12 +2,15 @@
|
|||
|
||||
## 1.17.1
|
||||
|
||||
- widgets
|
||||
- button: add `decoupled` property (restrict visual feedback to values received from osc/midi messages)
|
||||
|
||||
- scripting
|
||||
- add `updateCanvas()` function (forces a canvas widget to redraw)
|
||||
|
||||
- remote control
|
||||
- `/NOTIFY`: if multiple arguments are provided, interpret the first one as the icon's name for the client notification
|
||||
|
||||
|
||||
- midi
|
||||
- on Mac, name virtual ports after the device name to avoid confusion
|
||||
|
||||
|
|
|
|||
|
|
@ -137,6 +137,7 @@ Returns the value of the first matching widget. If the returned value is an obje
|
|||
- `sync: false`: prevents widgets from triggering synchronization and scripts
|
||||
- `script: false`: prevents scripts but not synchronization
|
||||
- `send: false`: prevents widgets from sending osc messages
|
||||
- `external: true`: simulates a value coming from an osc/midi message
|
||||
|
||||
Sets the value of the first matching widget. If `ìd` contains wildcards, affects all matching widgets **except** the emitting widget.
|
||||
|
||||
|
|
|
|||
|
|
@ -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