mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-21 11:29:29 +08:00
Support selecting files+dirs
This commit is contained in:
parent
d4224772b4
commit
0ec6707263
@ -29,6 +29,6 @@ extern void Fullscreen(void *app);
|
||||
extern void UnFullscreen(void *app);
|
||||
extern void ToggleFullscreen(void *app);
|
||||
extern void DisableFrame(void *app);
|
||||
extern void OpenDialog(void *appPointer, char *callbackID, char *title, char *filter);
|
||||
extern void OpenDialog(void *appPointer, char *callbackID, char *title, char *filter, int allowFiles, int allowDirs );
|
||||
|
||||
#endif
|
||||
|
@ -121,5 +121,11 @@ func (c *Client) WindowSetColour(colour int) {
|
||||
|
||||
// OpenDialog will open a dialog with the given title and filter
|
||||
func (c *Client) OpenDialog(dialogOptions *options.OpenDialog, callbackID string) {
|
||||
C.OpenDialog(c.app.app, c.app.string2CString(callbackID), c.app.string2CString(dialogOptions.Title), c.app.string2CString(dialogOptions.Filter))
|
||||
C.OpenDialog(c.app.app,
|
||||
c.app.string2CString(callbackID),
|
||||
c.app.string2CString(dialogOptions.Title),
|
||||
c.app.string2CString(dialogOptions.Filter),
|
||||
c.app.bool2Cint(dialogOptions.AllowFiles),
|
||||
c.app.bool2Cint(dialogOptions.AllowDirectories),
|
||||
)
|
||||
}
|
||||
|
@ -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) {
|
||||
void OpenDialog(struct Application *app, char* callbackID, char *title, char *filter, int allowFiles, int allowDirs) {
|
||||
Debug("OpenDialog Called with callback id: %s", callbackID);
|
||||
|
||||
// Create an open panel
|
||||
@ -428,6 +428,9 @@ void OpenDialog(struct Application *app, char* callbackID, char *title, char *fi
|
||||
// No filters: [dialog setAllowsOtherFileTypes:YES];
|
||||
|
||||
// TODO: Other options
|
||||
msg(dialog, s("setCanChooseFiles:"), allowFiles);
|
||||
msg(dialog, s("setCanChooseDirectories:"), allowDirs);
|
||||
|
||||
msg(dialog, s("beginSheetModalForWindow:completionHandler:"), app->mainWindow, ^(id result) {
|
||||
|
||||
JsonNode *response = json_mkarray();
|
||||
@ -451,7 +454,7 @@ void OpenDialog(struct Application *app, char* callbackID, char *title, char *fi
|
||||
free((void*)callback);
|
||||
free((void*)header);
|
||||
app->sendMessageToBackend(responseMessage);
|
||||
free(responseMessage);
|
||||
free((void*)responseMessage);
|
||||
});
|
||||
|
||||
msg( c("NSApp"), s("runModalForWindow:"), app->mainWindow);
|
||||
|
@ -67,11 +67,33 @@ func (r *RuntimeTest) SetColour(colour int) {
|
||||
r.runtime.Window.SetColour(colour)
|
||||
}
|
||||
|
||||
// OpenDialog will call the Runtime.Dialog.OpenDirectory method
|
||||
// OpenFileDialog will call the Runtime.Dialog.OpenDialog method requesting File selection
|
||||
func (r *RuntimeTest) OpenFileDialog(title string, filter string) []string {
|
||||
dialogOptions := &options.OpenDialog{
|
||||
Title: title,
|
||||
Filter: filter,
|
||||
AllowFiles: true,
|
||||
}
|
||||
return r.runtime.Dialog.Open(dialogOptions)
|
||||
}
|
||||
|
||||
// OpenDirectoryDialog will call the Runtime.Dialog.OpenDialog method requesting File selection
|
||||
func (r *RuntimeTest) OpenDirectoryDialog(title string, filter string) []string {
|
||||
dialogOptions := &options.OpenDialog{
|
||||
Title: title,
|
||||
Filter: filter,
|
||||
AllowDirectories: true,
|
||||
}
|
||||
return r.runtime.Dialog.Open(dialogOptions)
|
||||
}
|
||||
|
||||
// OpenDialog will call the Runtime.Dialog.OpenDialog method requesting both Files and Directories
|
||||
func (r *RuntimeTest) OpenDialog(title string, filter string) []string {
|
||||
dialogOptions := &options.OpenDialog{
|
||||
Title: title,
|
||||
Filter: filter,
|
||||
Title: title,
|
||||
Filter: filter,
|
||||
AllowDirectories: true,
|
||||
AllowFiles: true,
|
||||
}
|
||||
return r.runtime.Dialog.Open(dialogOptions)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user