mirror of https://github.com/buggins/dlangui.git
Merge pull request #325 from TheGag96/master
Allow FileDialog to select not-yet-existing files
This commit is contained in:
commit
f136bde35e
|
@ -460,7 +460,9 @@ class FileDialog : Dialog, CustomGridCellAdapter {
|
||||||
Action result = _action;
|
Action result = _action;
|
||||||
result.stringParam = _filename;
|
result.stringParam = _filename;
|
||||||
// success if either selected dir & has to open dir or if selected file
|
// success if either selected dir & has to open dir or if selected file
|
||||||
if (action.id == StandardAction.OpenDirectory && isDir(_filename) || isFile(_filename)) {
|
if (action.id == StandardAction.OpenDirectory && isDir(_filename) ||
|
||||||
|
action.id == StandardAction.Save && !(_flags & FileDialogFlag.FileMustExist) ||
|
||||||
|
isFile(_filename)) {
|
||||||
close(result);
|
close(result);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -540,6 +542,9 @@ class FileDialog : Dialog, CustomGridCellAdapter {
|
||||||
if (_flags & FileDialogFlag.SelectDirectory) {
|
if (_flags & FileDialogFlag.SelectDirectory) {
|
||||||
_edFilename.visibility = Visibility.Gone;
|
_edFilename.visibility = Visibility.Gone;
|
||||||
}
|
}
|
||||||
|
if ((_flags & FileDialogFlag.Save) && !(_flags & FileDialogFlag.FileMustExist)) {
|
||||||
|
_edFilename.contentChange = &onFilenameTyped;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//_edFilename.layoutWeight = 0;
|
//_edFilename.layoutWeight = 0;
|
||||||
|
@ -634,6 +639,10 @@ class FileDialog : Dialog, CustomGridCellAdapter {
|
||||||
override void onShow() {
|
override void onShow() {
|
||||||
_fileList.setFocus();
|
_fileList.setFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void onFilenameTyped(EditableContent content) {
|
||||||
|
_filename = _path ~ dirSeparator ~ toUTF8(content.text);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
interface OnPathSelectionHandler {
|
interface OnPathSelectionHandler {
|
||||||
|
@ -998,4 +1007,3 @@ class DirEditLine : FileNameEditLine {
|
||||||
}
|
}
|
||||||
|
|
||||||
//import dlangui.widgets.metadata;
|
//import dlangui.widgets.metadata;
|
||||||
//mixin(registerWidgets!(FileNameEditLine, DirEditLine)());
|
|
||||||
|
|
Loading…
Reference in New Issue