Skip to content

Commit

Permalink
Added additional documentation and example code snippet. (#2156)
Browse files Browse the repository at this point in the history
  • Loading branch information
lazyhacker committed May 22, 2021
1 parent ddc2a97 commit 8864cb4
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 7 deletions.
24 changes: 19 additions & 5 deletions dialog/file.go
Expand Up @@ -559,21 +559,31 @@ func (f *FileDialog) SetFileName(fileName string) {
}

// 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 dialog will appear over the window specified when Show() is called.
func NewFileOpen(callback func(fyne.URIReadCloser, 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.
// 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.
//
// The dialog will appear over the window specified when Show() is called.
func NewFileSave(callback func(fyne.URIWriteCloser, 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.
// 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.
//
// The dialog will appear over the window specified.
func ShowFileOpen(callback func(fyne.URIReadCloser, error), parent fyne.Window) {
dialog := NewFileOpen(callback, parent)
Expand All @@ -583,8 +593,12 @@ func ShowFileOpen(callback func(fyne.URIReadCloser, error), parent fyne.Window)
dialog.Show()
}

// 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.
// 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.
//
// The dialog will appear over the window specified.
func ShowFileSave(callback func(fyne.URIWriteCloser, error), parent fyne.Window) {
dialog := NewFileSave(callback, parent)
Expand Down
10 changes: 8 additions & 2 deletions dialog/folder.go
Expand Up @@ -7,7 +7,10 @@ import (

var folderFilter = storage.NewMimeTypeFileFilter([]string{"application/x-directory"})

// NewFolderOpen creates a file dialog allowing the user to choose a folder to open.
// NewFolderOpen creates a file dialog allowing the user to choose a folder 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 dialog will appear over the window specified when Show() is called.
//
// Since: 1.4
Expand All @@ -19,7 +22,10 @@ func NewFolderOpen(callback func(fyne.ListableURI, error), parent fyne.Window) *
return dialog
}

// ShowFolderOpen creates and shows a file dialog allowing the user to choose a folder to open.
// ShowFolderOpen creates and shows a file dialog allowing the user to choose a
// folder 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 dialog will appear over the window specified.
//
// Since: 1.4
Expand Down

0 comments on commit 8864cb4

Please sign in to comment.