dialog

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 2, 2026 License: MIT Imports: 2 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

Variables

View Source
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).

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.

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.

type Kind

type Kind = platform.MessageKind

Kind is a message dialog's icon / severity.

type 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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL