dialog
import "github.com/tangoui/tango/sys/dialog"本页由
site/tools/apigen从源码注释生成(按 darwin 构建标签选文件),请勿手改。
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).
常量
const (
Info = platform.MessageInfo
Warning = platform.MessageWarning
Error = platform.MessageError
Question = platform.MessageQuestion
)变量
var (
// ErrUnsupported is platform.ErrUnsupported.
ErrUnsupported = platform.ErrUnsupported
// ErrCanceled is platform.ErrCanceled.
ErrCanceled = platform.ErrCanceled
)函数
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).
func Open
func Open(a *tango.App, opts FileOptions) ([]string, error)Open shows an open dialog and returns the chosen paths (one unless Multiple). It returns ErrCanceled if the user dismissed it.
func Save
func Save(a *tango.App, opts FileOptions) (string, error)Save shows a save dialog and returns the chosen path. It returns ErrCanceled if the user dismissed it.
类型
FileFilter
type FileFilter = platform.FileFilterFileFilter restricts the files a file dialog offers, e.g. {Name: "Images", Patterns: []string{"*.png", "*.jpg"}}.
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.
Kind
type Kind = platform.MessageKindKind is a message dialog's icon / severity.
MessageOptions
type MessageOptions struct {
Parent *tango.Surface // attach to this surface (sheet / owner); nil for none
Kind Kind
Title string
Message string
Buttons []string // empty means a single "OK"
}MessageOptions configures Message.