widgets: set default address to "auto" and use id automatically
This commit is contained in:
parent
c291d3e9a2
commit
4295483fad
5 changed files with 10 additions and 12 deletions
|
|
@ -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 += '/'
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue