flyout

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: 8 Imported by: ? modules, 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 flyout shows a borderless panel under a tray icon — a popover in the macOS menu bar, a flyout above the Windows notification area — that hides itself when it loses focus.

t, _ := tray.New(a, tray.Options{Icon: png, Template: true, MenuOn: tray.MenuOnSecondary})
f, err := flyout.New(a, t, flyout.Options{Width: 320, Height: 420, URL: "/panel.html"})
// a left click on the icon now toggles the panel; f.Surface() is the page

The panel is an ordinary *tango.Surface (KindPanel, TitleBarNone, always on top, hidden until opened), so it can host a WebView page or, with Options.Surface, a surface the app created itself (a Go-drawn canvas surface, say). Open places it against the tray icon's bounds: below the icon when the icon is in the top half of its display (macOS menu bar, a top panel), above it when in the bottom half (Windows taskbar), beside it for vertical taskbars; always inside the display's work area. Where the platform does not report tray bounds (Linux AppIndicator) it goes to the top-right corner of the primary display's work area (bottom-right on Windows).

With a tray menu, set tray.Options.MenuOn = tray.MenuOnSecondary so left clicks reach the flyout and right clicks open the menu.

Methods are safe from any goroutine once the app runs.

Index

Constants

This section is empty.

Variables

View Source
var ErrClosed = errors.New("tango/flyout: the panel surface was closed")

ErrClosed is returned by Open after the panel's surface was closed.

Functions

func Place

func Place(anchor Rect, hasAnchor bool, work Rect, hasWork bool, w, h, gap int, bottomFallback bool) (x, y int)

Place computes the panel's top-left corner for a w x h panel against anchor (the tray icon) inside work (the work area of the anchor's display). Without an anchor the panel goes to the top-right corner of work, or the bottom-right when bottomFallback (Windows). Without a work area it is not clamped.

Types

type Flyout

type Flyout struct {
	// contains filtered or unexported fields
}

Flyout is a panel attached to a tray icon.

func New

func New(a *tango.App, t *tray.Tray, o Options) (*Flyout, error)

New creates the panel (hidden) and attaches it to t; t may be nil, in which case Open uses the fallback corner.

func (*Flyout) Close

func (f *Flyout) Close()

Close hides the panel.

func (*Flyout) IsOpen

func (f *Flyout) IsOpen() bool

IsOpen reports whether the panel is showing.

func (*Flyout) OnClose

func (f *Flyout) OnClose(fn func())

OnClose adds fn to run after the panel hid (Close, blur, Cmd+W).

func (*Flyout) OnOpen

func (f *Flyout) OnOpen(fn func())

OnOpen adds fn to run (on the main thread) after the panel opened.

func (*Flyout) Open

func (f *Flyout) Open() error

Open places the panel at the tray icon and shows and focuses it.

func (*Flyout) OpenAt

func (f *Flyout) OpenAt(anchor Rect, hasAnchor bool) error

OpenAt is Open against anchor instead of the tray icon's bounds (for example a point the app knows the user clicked: a 1x1 rect). With hasAnchor false it uses the fallback corner.

func (*Flyout) Surface

func (f *Flyout) Surface() *tango.Surface

Surface is the panel's surface.

func (*Flyout) Toggle

func (f *Flyout) Toggle()

Toggle opens the panel if it is hidden and closes it otherwise. A toggle right after the panel hid itself on blur — the click on the tray icon that caused the blur — leaves it closed.

type Options

type Options struct {
	Width, Height int    // panel size; default 320x400
	URL           string // page of the panel (relative to the asset origin); ignored with Surface
	Debug         bool   // allow the inspector
	Transparent   bool   // transparent window and page (round the corners in CSS)
	Material      tango.Material
	// Gap is the distance between the icon and the panel; default 6 px.
	Gap int
	// KeepOnBlur keeps the panel open when it loses focus.
	KeepOnBlur bool
	// NoToggle stops a primary click on the icon from toggling the panel;
	// call Open/Close/Toggle yourself.
	NoToggle bool
	// Surface, if set, is used as the panel instead of creating one. It
	// should be frameless and hidden; Close hides it, it is never closed.
	Surface *tango.Surface
	// contains filtered or unexported fields
}

Options configures a flyout.

type Rect

type Rect = tango.Rect

Rect is a screen rectangle in logical pixels.

Jump to

Keyboard shortcuts

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