Documentation
¶
Overview ¶
Package dialog shows native message and file dialogs.
Each function blocks its caller until the user answers. Called on the main thread (from a callback) it keeps the app's event loop running while it waits. A window's own UI thread instead waits for the main-thread dialog result without pumping frames of that window. Errors: ErrCanceled when the user dismissed a file dialog (or a message dialog with several buttons), ErrUnsupported when the backend has no dialogs, tango.ErrNotRunning after the app quit (or if it quits while the dialog is open).
Index ¶
Constants ¶
const ( Info = platform.MessageInfo Warning = platform.MessageWarning Error = platform.MessageError Question = platform.MessageQuestion )
Variables ¶
var ( // ErrUnsupported is platform.ErrUnsupported. ErrUnsupported = platform.ErrUnsupported // ErrCanceled is platform.ErrCanceled. ErrCanceled = platform.ErrCanceled )
Functions ¶
func Message ¶
func Message(a *tango.App, opts MessageOptions) (int, error)
Message shows a message dialog and returns the index of the button the user chose (0 for the default "OK").
If the user dismisses the dialog without choosing a button (Esc, the close box) Message returns (-1, ErrCanceled), except for a dialog with a single button, which reports that button: (0, nil).
Types ¶
type FileFilter ¶
type FileFilter = platform.FileFilter
FileFilter restricts the files a file dialog offers, e.g. {Name: "Images", Patterns: []string{"*.png", "*.jpg"}}.
type FileOptions ¶
type FileOptions struct {
Parent *tango.Surface
Title string
Directory string // initial directory
Filename string // Save: default file name
Filters []FileFilter
Multiple bool // Open: allow several files
PickFolders bool // Open: choose directories instead of files
// CanCreateDirs offers a "New Folder" button where the platform
// dialog lets the app choose (macOS, GTK); Windows always offers it.
CanCreateDirs bool
// ShowHidden lists hidden files (dot files, hidden attribute).
ShowHidden bool
}
FileOptions configures Open and Save.