remote control: add /SET method (issue #56)
This commit is contained in:
parent
2569dda2bd
commit
322c98ce6e
3 changed files with 49 additions and 0 deletions
|
|
@ -20,6 +20,7 @@
|
|||
- renamed `/EDIT_SOFT` to `/EDIT/MERGE`
|
||||
- added `/EDIT/GET` (get a widget's data)
|
||||
- added `/GET` (get a widget's value)
|
||||
- added `/SET` (set a widget's value as if it was interacted with from the interface)
|
||||
|
||||
|
||||
## 0.21.3
|
||||
|
|
|
|||
|
|
@ -68,6 +68,22 @@ Returns `/GET address preArg1 preArg2 ... value`
|
|||
- `value`: `*`
|
||||
|
||||
|
||||
## `/SET target id value`
|
||||
|
||||
Set a widget's value as if it was interacted with from the interface. This is likely to make it send its value.
|
||||
|
||||
- `id`: `string`, widget's `id`
|
||||
- `value`: `*`, widget's new value
|
||||
|
||||
## `/SET address preArg1 preArg2 ... value`
|
||||
|
||||
Set a widget's value as if it was interacted with from the interface. This is likely to make it send its value.
|
||||
|
||||
- `address`: `string`, widget's `address`
|
||||
- `preArg[1...]`: `*`, widget's `preArgs`
|
||||
- `value`: `*`, widget's new value
|
||||
|
||||
|
||||
## `/TABS id id etc`
|
||||
|
||||
Open the tabs designated by the `id` parameters. The target tab link must be accesible (opening a tab located in a disabled tab won't work unless you specify the parent tab's `id` before; the safest way to go is to pass the whole tab tree to enable).
|
||||
|
|
|
|||
|
|
@ -87,6 +87,38 @@ var callbacks = {
|
|||
|
||||
}
|
||||
|
||||
},
|
||||
'/SET':function(args) {
|
||||
|
||||
var [idOrAddress, ...preArgsOrValue] = args,
|
||||
widgets = [],
|
||||
value = null
|
||||
|
||||
if (idOrAddress[0] == '/') {
|
||||
|
||||
[widgets, value] = widgetManager.getWidgetByAddressAndArgs(
|
||||
idOrAddress,
|
||||
preArgsOrValue
|
||||
)
|
||||
|
||||
} else {
|
||||
|
||||
widgets = widgetManager.getWidgetById(idOrAddress)
|
||||
value = preArgsOrValue
|
||||
if (value.length == 0) value = null
|
||||
else if (value.length == 1) value = value[0]
|
||||
|
||||
}
|
||||
|
||||
for (var i = widgets.length - 1; i >= 0; i--) {
|
||||
|
||||
return widgets[i].setValue(value, {
|
||||
sync: true,
|
||||
send: true
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
},
|
||||
'/TABS': function(args) {
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue