scripting: scripting functions not working inside browseFile() callback

This commit is contained in:
jean-emmanuel 2023-08-19 07:38:06 +02:00
parent 28d06cc14a
commit aa1ee85f62
2 changed files with 16 additions and 1 deletions

View file

@ -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

View file

@ -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')