appctl
import "github.com/tangoui/tango/sys/appctl"本页由
site/tools/apigen从源码注释生成(按 darwin 构建标签选文件),请勿手改。
Package appctl controls the app as a whole in the window manager: hide and show all its windows, the dock / taskbar badge and progress bar, bouncing the dock icon or flashing the taskbar button, and the dock icon itself (tray-only apps).
appctl.SetBadge(app, "3") // "" clears
appctl.SetProgress(app, 0.5) // negative hides
appctl.RequestAttention(app, false)
Support by platform:
macOS Windows Linux
Hide / Show yes yes (all windows) yes (all windows)
SetBadge yes digits, as overlay icon digits, Unity launcher API (Ubuntu Dock, KDE)
SetProgress yes yes (taskbar) Unity launcher API
RequestAttention yes yes (FlashWindowEx) yes (urgency hint)
SetDockVisible yes no no
Functions are safe from any goroutine once the app runs. They return ErrUnsupported when the platform cannot do it (Supports tells beforehand), and tango.ErrNotRunning after the app quit. The badge and progress also appear on windows created after they were set.
常量
const (
CtlHide = platform.CtlHide // Hide, Show
CtlBadge = platform.CtlBadge // SetBadge with counts
CtlBadgeText = platform.CtlBadgeText // SetBadge with any text
CtlProgress = platform.CtlProgress // SetProgress
CtlAttention = platform.CtlAttention // RequestAttention
CtlDock = platform.CtlDock // SetDockVisible
)Operations, for Supports.
变量
var ErrUnsupported = platform.ErrUnsupportedErrUnsupported is platform.ErrUnsupported, re-exported for callers outside the module.
函数
func Hide
func Hide(a *tango.App) errorHide hides all of the app's windows (Cmd+H on macOS).
func RequestAttention
func RequestAttention(a *tango.App, critical bool) errorRequestAttention bounces the dock icon or flashes the taskbar button until the user activates the app. critical keeps it going on macOS (informational requests bounce once).
func SetBadge
func SetBadge(a *tango.App, text string) errorSetBadge shows text on the dock icon / taskbar button; "" clears it. Windows and Linux only show numbers: other text returns ErrUnsupported there (and clears the badge).
func SetDockVisible
func SetDockVisible(a *tango.App, visible bool) errorSetDockVisible shows or hides the app's dock icon (macOS). Without it the app has no menu bar either and lives in a tray icon.
func SetProgress
func SetProgress(a *tango.App, p float64) errorSetProgress shows a progress bar in [0, 1] on the dock icon / taskbar button; values above 1 are clamped, a negative value hides it.
func Show
func Show(a *tango.App) errorShow shows the windows Hide hid and brings the app to the front.
func Supports
func Supports(a *tango.App, op platform.AppControlOp) boolSupports reports whether the platform performs every operation in op.