mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-16 00:49:32 +08:00
[v3] Add window attachment for open/save dialogs. Fix filter bug.
This commit is contained in:
parent
722c3a653c
commit
2e313005e0
@ -179,6 +179,7 @@ type OpenFileDialogOptions struct {
|
|||||||
TreatsFilePackagesAsDirectories bool
|
TreatsFilePackagesAsDirectories bool
|
||||||
AllowsOtherFileTypes bool
|
AllowsOtherFileTypes bool
|
||||||
Filters []FileFilter
|
Filters []FileFilter
|
||||||
|
Window *WebviewWindow
|
||||||
|
|
||||||
Title string
|
Title string
|
||||||
Message string
|
Message string
|
||||||
@ -327,6 +328,7 @@ func (d *OpenFileDialog) SetOptions(options *OpenFileDialogOptions) {
|
|||||||
d.treatsFilePackagesAsDirectories = options.TreatsFilePackagesAsDirectories
|
d.treatsFilePackagesAsDirectories = options.TreatsFilePackagesAsDirectories
|
||||||
d.allowsOtherFileTypes = options.AllowsOtherFileTypes
|
d.allowsOtherFileTypes = options.AllowsOtherFileTypes
|
||||||
d.filters = options.Filters
|
d.filters = options.Filters
|
||||||
|
d.window = options.Window
|
||||||
}
|
}
|
||||||
|
|
||||||
func newOpenFileDialog() *OpenFileDialog {
|
func newOpenFileDialog() *OpenFileDialog {
|
||||||
@ -359,6 +361,7 @@ type SaveFileDialogOptions struct {
|
|||||||
Filename string
|
Filename string
|
||||||
ButtonText string
|
ButtonText string
|
||||||
Filters []FileFilter
|
Filters []FileFilter
|
||||||
|
Window *WebviewWindow
|
||||||
}
|
}
|
||||||
|
|
||||||
type SaveFileDialog struct {
|
type SaveFileDialog struct {
|
||||||
@ -397,6 +400,8 @@ func (d *SaveFileDialog) SetOptions(options *SaveFileDialogOptions) {
|
|||||||
d.directory = options.Directory
|
d.directory = options.Directory
|
||||||
d.filename = options.Filename
|
d.filename = options.Filename
|
||||||
d.buttonText = options.ButtonText
|
d.buttonText = options.ButtonText
|
||||||
|
d.filters = options.Filters
|
||||||
|
d.window = options.Window
|
||||||
}
|
}
|
||||||
|
|
||||||
// AddFilter adds a filter to the dialog. The filter is a display name and a semicolon separated list of extensions.
|
// AddFilter adds a filter to the dialog. The filter is a display name and a semicolon separated list of extensions.
|
||||||
|
@ -54,7 +54,7 @@ func (m *MessageProcessor) processDialogMethod(method string, rw http.ResponseWr
|
|||||||
case "Question":
|
case "Question":
|
||||||
dialog = globalApplication.QuestionDialog()
|
dialog = globalApplication.QuestionDialog()
|
||||||
}
|
}
|
||||||
var detached = params.Bool("Detached")
|
var detached = args.Bool("Detached")
|
||||||
if detached == nil || !*detached {
|
if detached == nil || !*detached {
|
||||||
dialog.AttachToWindow(window)
|
dialog.AttachToWindow(window)
|
||||||
}
|
}
|
||||||
@ -77,6 +77,10 @@ func (m *MessageProcessor) processDialogMethod(method string, rw http.ResponseWr
|
|||||||
m.httpError(rw, "Error parsing dialog options: %s", err.Error())
|
m.httpError(rw, "Error parsing dialog options: %s", err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
var detached = args.Bool("Detached")
|
||||||
|
if detached == nil || !*detached {
|
||||||
|
options.Window = window
|
||||||
|
}
|
||||||
dialog := globalApplication.OpenFileDialogWithOptions(&options)
|
dialog := globalApplication.OpenFileDialogWithOptions(&options)
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
@ -110,6 +114,10 @@ func (m *MessageProcessor) processDialogMethod(method string, rw http.ResponseWr
|
|||||||
m.httpError(rw, "Error parsing dialog options: %s", err.Error())
|
m.httpError(rw, "Error parsing dialog options: %s", err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
var detached = args.Bool("Detached")
|
||||||
|
if detached == nil || !*detached {
|
||||||
|
options.Window = window
|
||||||
|
}
|
||||||
dialog := globalApplication.SaveFileDialogWithOptions(&options)
|
dialog := globalApplication.SaveFileDialogWithOptions(&options)
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
|
Loading…
Reference in New Issue
Block a user