mirror of
https://github.com/taigrr/wails.git
synced 2026-04-02 05:08:54 -07:00
Support OpenDialog
This commit is contained in:
@@ -18,7 +18,7 @@ type Renderer interface {
|
||||
|
||||
// Dialog Runtime
|
||||
SelectFile(title string, filter string) string
|
||||
SelectDirectory() []string
|
||||
OpenDialog() []string
|
||||
SelectSaveFile(title string, filter string) string
|
||||
|
||||
// Window Runtime
|
||||
|
||||
@@ -119,10 +119,10 @@ func (h *Bridge) SelectFile(title string, filter string) string {
|
||||
return ""
|
||||
}
|
||||
|
||||
// SelectDirectory is unsupported for Bridge but required
|
||||
// OpenDialog is unsupported for Bridge but required
|
||||
// for the Renderer interface
|
||||
func (h *Bridge) SelectDirectory() string {
|
||||
h.log.Warn("SelectDirectory() unsupported in bridge mode")
|
||||
func (h *Bridge) OpenDialog() string {
|
||||
h.log.Warn("OpenDialog() unsupported in bridge mode")
|
||||
return ""
|
||||
}
|
||||
|
||||
|
||||
@@ -263,8 +263,8 @@ func (w *WebView) SelectFile(title string, filter string) string {
|
||||
return result
|
||||
}
|
||||
|
||||
// SelectDirectory opens a dialog that allows the user to select a directory
|
||||
func (w *WebView) SelectDirectory() []string {
|
||||
// OpenDialog opens a dialog that allows the user to select a directory
|
||||
func (w *WebView) OpenDialog() []string {
|
||||
var result string
|
||||
// We need to run this on the main thread, however Dispatch is
|
||||
// non-blocking so we launch this in a goroutine and wait for
|
||||
|
||||
@@ -31,9 +31,9 @@ func (r *Dialog) SelectFile(params ...string) string {
|
||||
return r.renderer.SelectFile(title, filter)
|
||||
}
|
||||
|
||||
// SelectDirectory prompts the user to select a directory
|
||||
func (r *Dialog) SelectDirectory() []string {
|
||||
return r.renderer.SelectDirectory()
|
||||
// OpenDialog prompts the user to select a directory
|
||||
func (r *Dialog) OpenDialog() []string {
|
||||
return r.renderer.OpenDialog()
|
||||
}
|
||||
|
||||
// SelectSaveFile prompts the user to select a file for saving
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
type Dialog interface {
|
||||
SaveFile(params ...string) string
|
||||
SelectFile(params ...string) string
|
||||
SelectDirectory(params ...string) []string
|
||||
OpenDialog(params ...string) []string
|
||||
}
|
||||
|
||||
// dialog exposes the Dialog interface
|
||||
@@ -107,8 +107,8 @@ func (r *dialog) SaveFile(params ...string) string {
|
||||
return result.Data().(string)
|
||||
}
|
||||
|
||||
// SelectDirectory prompts the user to select a file
|
||||
func (r *dialog) SelectDirectory(params ...string) []string {
|
||||
// OpenDialog prompts the user to select a file
|
||||
func (r *dialog) OpenDialog(params ...string) []string {
|
||||
|
||||
// Extract title + filter
|
||||
title, filter := r.processTitleAndFilter(params...)
|
||||
|
||||
@@ -76,9 +76,9 @@ func (r *RuntimeTest) SaveFile(title string, filter string) string {
|
||||
return r.runtime.Dialog.SaveFile(title, filter)
|
||||
}
|
||||
|
||||
// SelectDirectory will call the Runtime.Dialog.OpenDirectory method
|
||||
func (r *RuntimeTest) SelectDirectory(title string, filter string) []string {
|
||||
return r.runtime.Dialog.SelectDirectory(title, filter)
|
||||
// OpenDialog will call the Runtime.Dialog.OpenDirectory method
|
||||
func (r *RuntimeTest) OpenDialog(title string, filter string) []string {
|
||||
return r.runtime.Dialog.OpenDialog(title, filter)
|
||||
}
|
||||
|
||||
// HideWindow will call the Runtime.Window.Hide method and then call
|
||||
|
||||
Reference in New Issue
Block a user