scripting: add updateCanvas() function (forces a canvas widget to redraw
This commit is contained in:
parent
2ab69d29fb
commit
0b2fb7ea4a
3 changed files with 24 additions and 1 deletions
|
|
@ -2,6 +2,9 @@
|
|||
|
||||
## 1.18.0
|
||||
|
||||
- scripting
|
||||
- add `updateCanvas()` function (forces a canvas widget to redraw)
|
||||
|
||||
- remote control
|
||||
- `/NOTIFY`: if multiple arguments are provided, interpret the first one as the icon's name for the client notification
|
||||
|
||||
|
|
|
|||
|
|
@ -207,6 +207,13 @@ Forces a widget to check if one of its properties has changed and update itself
|
|||
|
||||
----
|
||||
|
||||
#### `updateCanvas(id)`
|
||||
- `id`: widget `id` as a string. Can be `"this"` to target the host widget.
|
||||
|
||||
Forces a canvas widget redraw.
|
||||
|
||||
----
|
||||
|
||||
#### `httpGet(url, callback)`
|
||||
|
||||
- `url`: url of the resource to fetch (local url only)
|
||||
|
|
|
|||
|
|
@ -223,6 +223,19 @@ class ScriptVm extends Vm {
|
|||
|
||||
}
|
||||
|
||||
this.sandbox.contentWindow.updateCanvas = (id)=>{
|
||||
|
||||
this.checkContext('updateCanvas')
|
||||
|
||||
var widgets = this.resolveId(id)
|
||||
for (var i = widgets.length - 1; i >= 0; i--) {
|
||||
|
||||
if (widgets[i].batchDraw) widgets[i].draw()
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
this.sandbox.contentWindow.getIndex = (id = 'this')=>{
|
||||
|
||||
this.checkContext('getIndex')
|
||||
|
|
@ -510,7 +523,7 @@ class ScriptVm extends Vm {
|
|||
|
||||
for (var imports of ['set', 'get', 'getProp', 'getIndex', 'updateProp', 'send', 'httpGet', 'stateGet', 'stateSet', 'storage',
|
||||
'setInterval', 'clearInterval', 'setTimeout', 'clearTimeout', 'setFocus', 'unfocus', 'setScroll', 'getScroll', 'toolbar',
|
||||
'openUrl', 'getVar', 'setVar', 'runAs', 'Image']) {
|
||||
'openUrl', 'getVar', 'setVar', 'runAs', 'Image', 'updateCanvas']) {
|
||||
this.sanitize(this.sandbox.contentWindow[imports])
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue