From 2ca83ccf297330bb4bf6e3d766b872e6267cef90 Mon Sep 17 00:00:00 2001 From: bordun Date: Mon, 4 Jul 2022 11:28:31 +0200 Subject: [PATCH] patchbay: add `exclusive` option and remove some seamingly wrong code --- CHANGELOG.md | 1 + src/client/widgets/containers/patchbay.js | 13 +++++-------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1b844518..f8a8a691 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ - widget - knob / encoder: `sensitivity` and ctrl+drag gesture preserve `circular` mode behavior - knob / encoder: `snap` mode now works like `circular` mode except for the touch start event (value can't jump from start to end anymore) + - patchbay: add `exclusive` option - editor - allow interacting with a widget without selecting it by using the middle mouse button or by holding shift+win (shift+cmd on mac). diff --git a/src/client/widgets/containers/patchbay.js b/src/client/widgets/containers/patchbay.js index df5321e2..d177f6fa 100644 --- a/src/client/widgets/containers/patchbay.js +++ b/src/client/widgets/containers/patchbay.js @@ -39,6 +39,10 @@ class PatchBayNode extends Widget { } } + if (this.parent.getProp('exclusive') && this.value.length > 1) { + this.value = [this.value.pop()] + } + this.parent.batchDraw() if (options.send) this.sendValue() @@ -85,6 +89,7 @@ class PatchBay extends Container(Canvas) { 'The inputs values can be consumed with the property inheritance syntax: `@{patchbay_id/input_1}` returns an array of output names connected to `input_1`' ]}, outputs: {type: 'array|object', value: ['output_1', 'output_2'], help: 'List of output values the inputs can connect to (see `inputs`).'}, + exclusive: {type: 'boolean', value: false, help: 'If set to `true`, each input will be allowed to have only one connection at a time.'}, } }) @@ -230,14 +235,6 @@ class PatchBay extends Container(Canvas) { this.batchDraw() } - if (this.connecting.length) { - var cb = (e)=>{ - this.toggleConnection() - this.off('fast-click', cb) - } - this.on('fast-click',cb, {element: this.widget}) - } - } draw() {