allow specifying args type by passing objects (buttons values and preArgs)

This commit is contained in:
jean-emmanuel 2016-03-28 18:34:26 +02:00
parent abdec11094
commit 00a8b20bc7
2 changed files with 11 additions and 4 deletions

View file

@ -24,15 +24,20 @@ module.exports = function(ipc, settings) {
if (typeof args=='object' && args!==null) {
for (i in args) {
var arg = args[i]
if (typeof arg == 'number' && arg!==null) {
if (typeof arg == 'number' && arg!==null && typeof arg != 'object') {
message.append({type:numberType,value:arg})
} else if (arg!==null){
} else if (arg!==null && typeof arg != 'object'){
message.append({type:'string',value:String(arg)})
}
} else if (arg!==null && typeof arg == 'object' && arg.type && arg.value!=undefined) {
message.append({type:arg.type,value:arg.value})
}
}
} else if (args!==null){
if (typeof args == 'number') {
message.append({type:numberType,value:args})
} else if (typeof args == 'object' && arg.type && arg.value!=undefined) {
message.append({type:args.type,value:args.value})
} else {
message.append({type:'string',value:String(args)})
}

View file

@ -20,6 +20,8 @@ Every widget has the following properties:
target:false, // [array/string] List of target hosts ("ip:port" pairs), separated by spaces
path:false, // [string] osc path, default to '/widget_id'
preArgs:[] // [array] list of constant values to prepend to the sent value(s)
// a value's type can be specified by writing it as an object:
// preArgs: [{type:"integer",value:1}]
}
```
@ -27,7 +29,7 @@ Every widget has the following properties:
## CSS
The css property can be used to override theming variables (see [theming](theming.md) for a widget. Also, some widgets expose specific theming variables that allow a finer customization.
The css property can be used to override theming variables (see [theming](theming.md) for a widget. Also, some widgets expose specific theming variables that allow a finer customization.
## Widget specifics