5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-12 23:19:29 +08:00

Filter support

This commit is contained in:
Lea Anthony 2020-09-27 20:26:16 +10:00
parent 762632d55a
commit ac27137e5a
No known key found for this signature in database
GPG Key ID: 33DAF7BB90A58405
2 changed files with 12 additions and 3 deletions

View File

@ -428,8 +428,16 @@ void OpenDialog(struct Application *app, char *callbackID, char *title, char *fi
// Valid but appears to do nothing.... :/ // Valid but appears to do nothing.... :/
msg(dialog, s("setTitle:"), str(title)); msg(dialog, s("setTitle:"), str(title));
// TODO: Filters // Filters
// No filters: [dialog setAllowsOtherFileTypes:YES]; if( filter != NULL && strlen(filter) > 0) {
Debug("Using filter: %s", filter);
id filterString = msg(str(filter), s("stringByReplacingOccurrencesOfString:withString:"), str("*."), str(""));
filterString = msg(filterString, s("stringByReplacingOccurrencesOfString:withString:"), str(" "), str(""));
id filterList = msg(filterString, s("componentsSeparatedByString:"), str(","));
msg(dialog, s("setAllowedFileTypes:"), filterList);
} else {
msg(dialog, s("setAllowsOtherFileTypes:"), YES);
}
// Setup Options // Setup Options
msg(dialog, s("setCanChooseFiles:"), allowFiles); msg(dialog, s("setCanChooseFiles:"), allowFiles);

View File

@ -111,8 +111,9 @@ func (r *RuntimeTest) OpenDialogMultiple(title string, filter string) []string {
} }
// OpenDialogAllOptions will call the Runtime.Dialog.OpenDialog method allowing multiple selection // OpenDialogAllOptions will call the Runtime.Dialog.OpenDialog method allowing multiple selection
func (r *RuntimeTest) OpenDialogAllOptions() []string { func (r *RuntimeTest) OpenDialogAllOptions(filter string) []string {
dialogOptions := &options.OpenDialog{ dialogOptions := &options.OpenDialog{
Filter: filter,
AllowFiles: true, AllowFiles: true,
AllowDirectories: true, AllowDirectories: true,
ShowHiddenFiles: true, ShowHiddenFiles: true,