file: add mode property, for choosing between open and save modes

This commit is contained in:
bordun 2021-01-26 08:51:46 +01:00
parent 68aeecd8b0
commit 8e3e6266c5
2 changed files with 8 additions and 1 deletions

View file

@ -1,5 +1,10 @@
# Changelog
## 1.8.4
- widgets
- file: add `mode` property, for choosing between `open` and `save` modes
## 1.8.3
- bug fixes

View file

@ -17,6 +17,7 @@ module.exports = class File extends Widget {
_separator_file_style: 'File style',
align: {type: 'string', value: 'center', choices: ['center', 'left', 'right'], help: 'Set to `left` or `right` to change text alignment (otherwise center)'},
hidePath: {type: 'boolean', value: false, help: 'Set to `true` to only display the filename (the whole path will still be used as value)'},
mode: {type: 'string', value: 'open', choices: ['open', 'save'], help: 'File browser mode'},
},
class_specific: {
directory: {type: 'string', value: 'auto', help: 'Default browsing directory'},
@ -47,7 +48,8 @@ module.exports = class File extends Widget {
uiFilebrowser({
extension: this.getProp('extension').replace(/^\.?(.*)$/, '$1'),
directory: this.getProp('directory') === 'auto' ? undefined : this.getProp('directory'),
loadDir: this.getProp('allowDir')
loadDir: this.getProp('allowDir'),
save: this.getProp('mode') === 'save'
}, (path)=>{
this.setValue(path.join(path[0][0] === '/' ? '/' : '\\'), {