diff --git a/src/client/editor/index.js b/src/client/editor/index.js index aa431dd9..90da49b8 100644 --- a/src/client/editor/index.js +++ b/src/client/editor/index.js @@ -30,10 +30,7 @@ class Editor { newWidgets = [] for (var w of this.selectedWidgets) { - if (propName === 'address' && value === '') { - // special case - w.props[propName] = '/' + w.props.id - } else if ((propName === 'label' || propName === 'popupLabel') && value === true) { + if ((propName === 'label' || propName === 'popupLabel') && value === true) { w.props[propName] = 'auto' } else { w.props[propName] = value !== '' ? value : deepCopy(defaults[w.props.type][propName].value) diff --git a/src/client/managers/widgets.js b/src/client/managers/widgets.js index 0472dc3a..c8b2422b 100644 --- a/src/client/managers/widgets.js +++ b/src/client/managers/widgets.js @@ -143,7 +143,7 @@ class WidgetManager extends EventEmitter { preArgs: widget.getProp('preArgs'), target: widget.getProp('target'), typeTags: widget.getProp('typeTags'), - address: widget.getProp('address'), + address: widget.getProp('address') === 'auto' ? '/' + widget.getProp('id') : widget.getProp('address'), } }) diff --git a/src/client/parser.js b/src/client/parser.js index e4a63533..28702e57 100644 --- a/src/client/parser.js +++ b/src/client/parser.js @@ -67,10 +67,6 @@ var Parser = class Parser { props.id = id } - // Generate default address (also handled in editor/edit-field) - props.address = props.address === 'auto' ? '/' + props.id : props.address - - // Remove props that don't apply for (let j in props) { if (defaults[j] === undefined || j[0] === '_') delete props[j] diff --git a/src/client/widgets/common/osc-receiver.js b/src/client/widgets/common/osc-receiver.js index a21b97a6..3f3ed4b2 100644 --- a/src/client/widgets/common/osc-receiver.js +++ b/src/client/widgets/common/osc-receiver.js @@ -35,7 +35,9 @@ module.exports = class OscReceiver { if (address) this.address = address if (this.address[0] !== '/') { - this.prefix = this.parent.getProp('address') || this.parent.resolveProp('address', undefined, false, this) + var parentAddress = this.parent.getProp('address') || this.parent.resolveProp('address', undefined, false, this) + if (parentAddress === 'auto') parentAddress = '/' + this.parent.getProp('id') + this.prefix = parentAddress if (this.prefix[this.prefix.length - 1] !== '/') this.prefix += '/' } diff --git a/src/client/widgets/common/widget.js b/src/client/widgets/common/widget.js index 5c9befbf..c5977b2e 100644 --- a/src/client/widgets/common/widget.js +++ b/src/client/widgets/common/widget.js @@ -103,7 +103,10 @@ class Widget extends EventEmitter { _osc: 'osc', - address: {type: 'string', value: 'auto', help: 'OSC address for sending messages, it must start with a /'}, + address: {type: 'string', value: 'auto', help: [ + 'OSC address for sending / receiving messages, it must start with a slash (`/`)', + 'By default ("auto"), the widget\'s id is used: `/widget_id`', + ]}, preArgs: {type: '*|array', value: '', help: [ 'A value or array of values that will be prepended to the OSC messages.', ]}, @@ -837,7 +840,7 @@ class Widget extends EventEmitter { var data = {}, oldData = { preArgs: propName == 'preArgs' ? oldPropValue : this.getProp('preArgs'), - address: propName == 'address' ? oldPropValue : this.getProp('address') + address: propName == 'address' ? oldPropValue : (this.getProp('address') === 'auto' ? '/' + this.getProp('id') : this.getProp('address')) } data[propName] = this.getProp(propName) widgetManager.registerWidget(this, data, oldData)