From 7e9a602ceb4fe424d112b09630e3a37972f6f4a2 Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Fri, 28 Dec 2018 14:05:32 +0100 Subject: [PATCH] push: add doubleTap option (#447) --- CHANGELOG.md | 4 +++- src/client/app/widgets/buttons/push.js | 22 ++++++++++++++++++---- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e0bfcf72..cd7ebb24 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,9 @@ - bug fixes - editor: widgets/tabs not properly reordered when changing a widget or tab's index by more than 1 - main: `--no-gui` switch not working when running the app from a different directory - +- widgets + - push: add `doubleTap` option + ## 0.40.3 - bug fixes diff --git a/src/client/app/widgets/buttons/push.js b/src/client/app/widgets/buttons/push.js index cc124dc5..d250d6ee 100644 --- a/src/client/app/widgets/buttons/push.js +++ b/src/client/app/widgets/buttons/push.js @@ -1,4 +1,5 @@ var Widget = require('../common/widget'), + doubletab = require('../mixins/double_tap'), osc = require('../../osc'), html = require('nanohtml') @@ -11,6 +12,7 @@ class Push extends Widget { _push: 'push', + 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'}, on: {type: '*', value: 1, help: [ 'Set to `null` to send send no argument in the osc message', 'Can be an `object` if the type needs to be specified (see preArgs)' @@ -33,12 +35,24 @@ class Push extends Widget { this.active = 0 this.lastChanged = 'state' - this.on('draginit',()=>{ - if (this.active) return - this.setValuePrivate(this.getProp('on'),{send:true,sync:true}) - }, {element: this.widget}) + if (this.getProp('doubleTap')) { + + doubletab(this.widget, ()=>{ + if (this.active) return + this.setValuePrivate(this.getProp('on'),{send:true,sync:true}) + }) + + } else { + + this.on('draginit',()=>{ + if (this.active) return + this.setValuePrivate(this.getProp('on'),{send:true,sync:true}) + }, {element: this.widget}) + + } this.on('dragend',()=>{ + if (!this.active) return this.setValuePrivate(this.getProp('off'),{send:true,sync:true}) }, {element: this.widget})