diff --git a/dialog/file.go b/dialog/file.go index 738cfb7b78..32a0bc3859 100644 --- a/dialog/file.go +++ b/dialog/file.go @@ -831,33 +831,40 @@ func (f *FileDialog) SetView(v ViewLayout) { } // NewFileOpen creates a file dialog allowing the user to choose a file to open. -// The callback function will run when the dialog closes. The URI will be nil -// when the user cancels or when nothing is selected. +// +// The callback function will run when the dialog closes and provide a reader for the chosen file. +// The reader will be nil when the user cancels or when nothing is selected. +// When the reader isn't nil it must be closed by the callback. // // The dialog will appear over the window specified when Show() is called. -func NewFileOpen(callback func(fyne.URIReadCloser, error), parent fyne.Window) *FileDialog { +func NewFileOpen(callback func(reader fyne.URIReadCloser, err error), parent fyne.Window) *FileDialog { dialog := &FileDialog{callback: callback, parent: parent} return dialog } // NewFileSave creates a file dialog allowing the user to choose a file to save // to (new or overwrite). If the user chooses an existing file they will be -// asked if they are sure. The callback function will run when the dialog -// closes. The URI will be nil when the user cancels or when nothing is -// selected. +// asked if they are sure. +// +// The callback function will run when the dialog closes and provide a writer for the chosen file. +// The writer will be nil when the user cancels or when nothing is selected. +// When the writer isn't nil it must be closed by the callback. // // The dialog will appear over the window specified when Show() is called. -func NewFileSave(callback func(fyne.URIWriteCloser, error), parent fyne.Window) *FileDialog { +func NewFileSave(callback func(writer fyne.URIWriteCloser, err error), parent fyne.Window) *FileDialog { dialog := &FileDialog{callback: callback, parent: parent, save: true} return dialog } // ShowFileOpen creates and shows a file dialog allowing the user to choose a -// file to open. The callback function will run when the dialog closes. The URI -// will be nil when the user cancels or when nothing is selected. +// file to open. +// +// The callback function will run when the dialog closes and provide a reader for the chosen file. +// The reader will be nil when the user cancels or when nothing is selected. +// When the reader isn't nil it must be closed by the callback. // // The dialog will appear over the window specified. -func ShowFileOpen(callback func(fyne.URIReadCloser, error), parent fyne.Window) { +func ShowFileOpen(callback func(reader fyne.URIReadCloser, err error), parent fyne.Window) { dialog := NewFileOpen(callback, parent) if fileOpenOSOverride(dialog) { return @@ -867,12 +874,14 @@ func ShowFileOpen(callback func(fyne.URIReadCloser, error), parent fyne.Window) // ShowFileSave creates and shows a file dialog allowing the user to choose a // file to save to (new or overwrite). If the user chooses an existing file they -// will be asked if they are sure. The callback function will run when the -// dialog closes. The URI will be nil when the user cancels or when nothing is -// selected. +// will be asked if they are sure. +// +// The callback function will run when the dialog closes and provide a writer for the chosen file. +// The writer will be nil when the user cancels or when nothing is selected. +// When the writer isn't nil it must be closed by the callback. // // The dialog will appear over the window specified. -func ShowFileSave(callback func(fyne.URIWriteCloser, error), parent fyne.Window) { +func ShowFileSave(callback func(writer fyne.URIWriteCloser, err error), parent fyne.Window) { dialog := NewFileSave(callback, parent) if fileSaveOSOverride(dialog) { return