mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-12 23:19:29 +08:00
Filter support
This commit is contained in:
parent
762632d55a
commit
ac27137e5a
@ -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);
|
||||||
|
@ -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,
|
||||||
|
Loading…
Reference in New Issue
Block a user