alert

package
v0.1.16 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2026 License: MIT Imports: 5 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 alert shows the operating system's modal alert: a message, a row of buttons and, when asked, one line of text to type, cgo-free.

Threading: the alert is platform UI and must be shown from the main thread, as with filedialog; an Ebitengine app wraps the call in ebiten.RunOnMainThread.

Implemented on macOS (NSAlert) and Linux (a GtkDialog, GTK3 or GTK4, joining the GTK the process already loaded). Elsewhere Show returns ErrUnsupported, and the caller keeps a dialog of its own.

Index

Constants

This section is empty.

Variables

View Source
var ErrUnsupported = fmt.Errorf("alert: not supported on this platform: %w", errors.ErrUnsupported)

Functions

This section is empty.

Types

type Button

type Button struct {
	Title       string
	Cancel      bool
	Destructive bool
}

Button is one choice. Cancel makes Escape choose it; Destructive draws it the platform's way for an action that loses something.

type Options

type Options struct {
	Title   string
	Message string
	Buttons []Button
	Input   bool   // show a one-line text field
	Text    string // what the field starts with
}

Options describes one alert. Buttons go most important first: the first is the default, answered by Return, and the system lays them out (on macOS the first is rightmost).

type Result

type Result struct {
	Button int
	Text   string
}

Result is the index of the chosen button in Options.Buttons and, with Input, what the field held when it was chosen.

func Show

func Show(opts Options) (Result, error)

Jump to

Keyboard shortcuts

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