Support OpenDialog

This commit is contained in:
Lea Anthony
2020-09-26 16:08:55 +10:00
parent bed5619d4e
commit 9b0f58ddf5
6 changed files with 15 additions and 15 deletions

View File

@@ -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

View File

@@ -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 ""
}

View File

@@ -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

View File

@@ -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

View File

@@ -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...)

View File

@@ -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