diff --git a/CHANGELOG.md b/CHANGELOG.md index 08610e5b..6de207b1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ - input: rendering issues with big font sizes - panel: tab rendering issue when initialized with a non-numeric value - panel: minor style issue in tab navigation bar + - scripting: scripting functions not working inside `browseFile()` callback ## 1.25.2 diff --git a/src/client/widgets/scripts/script-vm.js b/src/client/widgets/scripts/script-vm.js index 53c4706c..5ad0f5ee 100644 --- a/src/client/widgets/scripts/script-vm.js +++ b/src/client/widgets/scripts/script-vm.js @@ -569,14 +569,28 @@ class ScriptVm extends Vm { callback = options options = {} } + + if (typeof callback === 'function') { + + var widget = this.getWidget(), + valueOptions = this.getValueOptions() + uiFilebrowser({ extension: options.extention || '*', directory: options.directory || undefined, loadDir: !!options.allowDir, save: options.mode === 'save' }, (path)=>{ - callback(path.join(path[0][0] === '/' ? '/' : '\\')) + this.setWidget(widget) + this.setValueOptions(valueOptions) + try { + callback(path.join(path[0][0] === '/' ? '/' : '\\')) + } catch(e) { + widget.errorProp('script', 'browseFile', e) + } + this.setWidget() + this.setValueOptions() }) } else { widget.errorProp('script', 'browseFile', 'callback argument must be a function')