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 ¶
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 ¶
New creates the panel (hidden) and attaches it to t; t may be nil, in which case Open uses the fallback corner.
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.
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.