button: add onTouch
This commit is contained in:
parent
934550c942
commit
b064b8f3a8
2 changed files with 24 additions and 0 deletions
|
|
@ -19,6 +19,7 @@
|
|||
- add new `scrollbar` widget that connects to a scrolling container widget and acts as it scrollbar
|
||||
- input: add `noCanvas` option to avoid blurry text under some circumstances
|
||||
- xy: add `clipX` and `clipY` proprties (allows multixy to set per-pads anges limits)
|
||||
- button: add `onTouch` script
|
||||
|
||||
- editor
|
||||
- selecting a widget automatically shows it in the widget tree if it's not minimized
|
||||
|
|
|
|||
|
|
@ -51,6 +51,9 @@ class Button extends Widget {
|
|||
'From a script property, feedback messages can be simulated with:',
|
||||
'`set("widget_id", value, {external: true})`'
|
||||
]},
|
||||
},
|
||||
scripting: {
|
||||
onTouch: {type: 'script', value: '', editor:'javascript', help: ['Script executed when the panel is touched and released, and when the pointer moves when the widget is touched. See <a href="https://openstagecontrol.ammd.net/docs/widgets/canvas/">documentation</a>.',]},
|
||||
}
|
||||
})
|
||||
|
||||
|
|
@ -84,6 +87,10 @@ class Button extends Widget {
|
|||
}, {element: this.widget})
|
||||
}
|
||||
|
||||
if (this.getProp('onTouch')) {
|
||||
this.on('draginit',(e)=>this.onTouch(e, 'start'), {element: this.container})
|
||||
}
|
||||
|
||||
var mode = this.getProp('mode'),
|
||||
tap = mode === 'momentary' || mode === 'tap',
|
||||
push = mode === 'push' || tap
|
||||
|
|
@ -219,8 +226,24 @@ class Button extends Widget {
|
|||
|
||||
}
|
||||
|
||||
if (this.getProp('onTouch')) {
|
||||
this.on('dragend',(e)=>this.onTouch(e, 'stop'), {element: this.container})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
onTouch(e, name) {
|
||||
|
||||
var event = {...e}
|
||||
|
||||
event.type = name
|
||||
|
||||
this.scripts.onTouch.run({
|
||||
value: this.value,
|
||||
event: event
|
||||
}, {sync: true, send: true})
|
||||
|
||||
}
|
||||
|
||||
get value() {
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue