5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-10 01:50:36 +08:00

Support multiple files in dialog

This commit is contained in:
Lea Anthony 2020-09-27 14:49:38 +10:00
parent 0ec6707263
commit 8666935caf
No known key found for this signature in database
GPG Key ID: 33DAF7BB90A58405
3 changed files with 15 additions and 1 deletions

View File

@ -416,7 +416,7 @@ char* OpenFileDialog(struct Application *app, char *title, char *filter) {
// OpenDialog opens a dialog to select files/directories
// NOTE: The result is a string that will need to be freed!
void OpenDialog(struct Application *app, char* callbackID, char *title, char *filter, int allowFiles, int allowDirs) {
void OpenDialog(struct Application *app, char* callbackID, char *title, char *filter, int allowFiles, int allowDirs, int allowMultiple) {
Debug("OpenDialog Called with callback id: %s", callbackID);
// Create an open panel
@ -430,6 +430,7 @@ void OpenDialog(struct Application *app, char* callbackID, char *title, char *fi
// TODO: Other options
msg(dialog, s("setCanChooseFiles:"), allowFiles);
msg(dialog, s("setCanChooseDirectories:"), allowDirs);
msg(dialog, s("setAllowsMultipleSelection:"), allowMultiple);
msg(dialog, s("beginSheetModalForWindow:completionHandler:"), app->mainWindow, ^(id result) {

View File

@ -6,4 +6,5 @@ type OpenDialog struct {
Filter string
AllowFiles bool
AllowDirectories bool
AllowMultiple bool
}

View File

@ -98,6 +98,18 @@ func (r *RuntimeTest) OpenDialog(title string, filter string) []string {
return r.runtime.Dialog.Open(dialogOptions)
}
// OpenDialogMultiple will call the Runtime.Dialog.OpenDialog method allowing multiple selection
func (r *RuntimeTest) OpenDialogMultiple(title string, filter string) []string {
dialogOptions := &options.OpenDialog{
Title: title,
Filter: filter,
AllowDirectories: true,
AllowFiles: true,
AllowMultiple: true,
}
return r.runtime.Dialog.Open(dialogOptions)
}
// HideWindow will call the Runtime.Window.Hide method and then call
// Runtime.Window.Show 3 seconds later.
func (r *RuntimeTest) HideWindow() {