From afc82abd6e6efa17b3f404b8a33bef0ee8b54d4b Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Fri, 4 May 2018 21:25:15 +0200 Subject: [PATCH] widgets: target: make 'null' token disable the global default target (#279) --- CHANGELOG.md | 3 ++- app/main/callbacks.js | 8 +++++--- resources/docs/widgets/widgets.md | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 98879c02..711be211 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,8 @@ - widgets - `target` and `preArgs` properties are no longer coerced to arrays and can be written as single string values - - `linkId` supports master and slave mode with `>>` and `>>` prefixes + - `linkId` supports master and slave mode with `>>` and `>>` prefixes + - the special `target` token `null` can now be used in conjunction with regular targets, it disables the default global targets set via the `--send` option ## 0.29.2 diff --git a/app/main/callbacks.js b/app/main/callbacks.js index 1e65f9ca..84402716 100644 --- a/app/main/callbacks.js +++ b/app/main/callbacks.js @@ -176,18 +176,20 @@ module.exports = { data.args = data.preArgs ? data.preArgs.concat(value) : [value] - if (!data.target || data.target.indexOf(null) == -1) { + if (data.target) { var targets = [] - if (settings.read('targets') && !shortdata.target) Array.prototype.push.apply(targets, settings.read('targets')) + if (data.target.indexOf(null) === -1 && settings.read('targets') && !shortdata.target) Array.prototype.push.apply(targets, settings.read('targets')) if (data.target) Array.prototype.push.apply(targets, data.target) for (var i in targets) { - if (targets[i] == 'self') { + if (targets[i] === 'self') { ipc.send('receiveOsc',data,clientId) continue + } else if (targets[i] === null) { + continue } var host = targets[i].split(':')[0], diff --git a/resources/docs/widgets/widgets.md b/resources/docs/widgets/widgets.md index 2cc13554..7c73b49b 100644 --- a/resources/docs/widgets/widgets.md +++ b/resources/docs/widgets/widgets.md @@ -90,7 +90,7 @@ All widgets share a set of generic properties described below. - if [`midi`](../extras/midi.md) is enabled, targets can be `"midi:device_name"` - special item `"self"` can be used to refer to the emitting client directly - if no target is set (empty array `[]`), messages can still be sent if the server has defaults targets (`-s / --send`) - - to disable osc regardless of the previous point, set `target` to `[null]` + - to disable the default global osc targets (set via the app's `--send` option), set one of the array's item as `null` (unquoted). ### `address` - type: `string`