mirror of
https://github.com/taigrr/wails.git
synced 2026-04-02 05:08:54 -07:00
Support selecting files+dirs
This commit is contained in:
@@ -29,6 +29,6 @@ extern void Fullscreen(void *app);
|
|||||||
extern void UnFullscreen(void *app);
|
extern void UnFullscreen(void *app);
|
||||||
extern void ToggleFullscreen(void *app);
|
extern void ToggleFullscreen(void *app);
|
||||||
extern void DisableFrame(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
|
#endif
|
||||||
|
|||||||
@@ -121,5 +121,11 @@ func (c *Client) WindowSetColour(colour int) {
|
|||||||
|
|
||||||
// OpenDialog will open a dialog with the given title and filter
|
// OpenDialog will open a dialog with the given title and filter
|
||||||
func (c *Client) OpenDialog(dialogOptions *options.OpenDialog, callbackID string) {
|
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
|
// OpenDialog opens a dialog to select files/directories
|
||||||
// NOTE: The result is a string that will need to be freed!
|
// 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);
|
Debug("OpenDialog Called with callback id: %s", callbackID);
|
||||||
|
|
||||||
// Create an open panel
|
// Create an open panel
|
||||||
@@ -428,6 +428,9 @@ void OpenDialog(struct Application *app, char* callbackID, char *title, char *fi
|
|||||||
// No filters: [dialog setAllowsOtherFileTypes:YES];
|
// No filters: [dialog setAllowsOtherFileTypes:YES];
|
||||||
|
|
||||||
// TODO: Other options
|
// TODO: Other options
|
||||||
|
msg(dialog, s("setCanChooseFiles:"), allowFiles);
|
||||||
|
msg(dialog, s("setCanChooseDirectories:"), allowDirs);
|
||||||
|
|
||||||
msg(dialog, s("beginSheetModalForWindow:completionHandler:"), app->mainWindow, ^(id result) {
|
msg(dialog, s("beginSheetModalForWindow:completionHandler:"), app->mainWindow, ^(id result) {
|
||||||
|
|
||||||
JsonNode *response = json_mkarray();
|
JsonNode *response = json_mkarray();
|
||||||
@@ -451,7 +454,7 @@ void OpenDialog(struct Application *app, char* callbackID, char *title, char *fi
|
|||||||
free((void*)callback);
|
free((void*)callback);
|
||||||
free((void*)header);
|
free((void*)header);
|
||||||
app->sendMessageToBackend(responseMessage);
|
app->sendMessageToBackend(responseMessage);
|
||||||
free(responseMessage);
|
free((void*)responseMessage);
|
||||||
});
|
});
|
||||||
|
|
||||||
msg( c("NSApp"), s("runModalForWindow:"), app->mainWindow);
|
msg( c("NSApp"), s("runModalForWindow:"), app->mainWindow);
|
||||||
|
|||||||
@@ -67,11 +67,33 @@ func (r *RuntimeTest) SetColour(colour int) {
|
|||||||
r.runtime.Window.SetColour(colour)
|
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 {
|
func (r *RuntimeTest) OpenDialog(title string, filter string) []string {
|
||||||
dialogOptions := &options.OpenDialog{
|
dialogOptions := &options.OpenDialog{
|
||||||
Title: title,
|
Title: title,
|
||||||
Filter: filter,
|
Filter: filter,
|
||||||
|
AllowDirectories: true,
|
||||||
|
AllowFiles: true,
|
||||||
}
|
}
|
||||||
return r.runtime.Dialog.Open(dialogOptions)
|
return r.runtime.Dialog.Open(dialogOptions)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user