Documentation
¶
Overview ¶
Package app runs a jamb application: it opens native windows, creates the GPU renderer and drives one ui runtime per window.
func main() {
app.New().Run(app.Window{
Title: "Hello", Width: 800, Height: 600,
Root: func(ctx *ui.Context) ui.Element { return ui.Text("Hello") },
})
}
Further windows open with Open, from event handlers or from goroutines. All windows share the UI thread, one text system and one GPU device; each has its own ui runtime, theme, zoom, focus and key bindings.
Example ¶
A one-window application. It is compiled, not run, by the tests.
package main
import (
"github.com/tyler-builds/jamb/app"
"github.com/tyler-builds/jamb/ui"
)
func main() {
app.New().Run(app.Window{
Title: "Hello", Width: 800, Height: 600,
Root: func(ctx *ui.Context) ui.Element { return ui.Text("Hello") },
})
}
Output:
Index ¶
- func AddRecentDocument(path string)
- func ClearNotifications() error
- func FileIcon(path string, size int) (image.Image, error)
- func Notify(n Notification) error
- func Open(w Window) ui.Window
- func OpenDockWindow(w ui.DockWindow) ui.Window
- func Quit()
- func RegisterControl()
- func RegisterInspector()
- func RegisterScenes(names func() []string, ...)
- func RemoveNotification(tag string) error
- type App
- func (a *App) AppID(id string) *App
- func (a *App) DevTools(on bool) *App
- func (a *App) FallbackFont(data []byte) *App
- func (a *App) Font(family string, weight ui.FontWeight, data []byte) *App
- func (a *App) JumpList(j JumpList) *App
- func (a *App) KeepRunning(on bool) *App
- func (a *App) OnNotification(fn func(n NotificationActivation)) *App
- func (a *App) Run(w Window)
- func (a *App) RunE(w Window) error
- func (a *App) SingleInstance(onArgs func(args []string, dir string)) *App
- type Changes
- type Chrome
- type Corners
- type JumpList
- type JumpTask
- type Notification
- type NotificationAction
- type NotificationActivation
- type Tray
- type TrayItem
- type TrayOptions
- type Window
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddRecentDocument ¶
func AddRecentDocument(path string)
AddRecentDocument adds the file at path to the Recent category of the app's jump list, which the app shows when JumpList.Recent is set. Call it for each file the app opens or saves. A relative path is made absolute first, because Windows needs the full path. Windows keeps the list and drops old entries itself. It does nothing on platforms other than Windows.
func ClearNotifications ¶
func ClearNotifications() error
ClearNotifications removes every notification the app has shown.
func FileIcon ¶ added in v0.5.0
FileIcon returns the icon that Windows shows for the file at path, size pixels square, as File Explorer and Task Manager show it: the file's own icon when it holds one (an executable, a library or an .ico file), at that size, and otherwise the icon of its type, scaled to size. Pass the size in pixels of the display: a 16-pixel icon on a display at 150 percent is 24 pixels square. Show it with ui.ImageFromImage.
img, err := app.FileIcon(`C:\Windows\explorer.exe`, 32)
if err == nil {
icon := ui.Image(ui.ImageFromImage(img)).Size(ui.Px(16), ui.Px(16))
}
It reads the file, so call it off the UI thread for many files, and keep the images by path. It is safe from any goroutine. A file Windows has no icon for, a path that does not exist and a size of zero give an error. It is a Windows feature, and gives an error on other platforms.
func Notify ¶
func Notify(n Notification) error
Notify shows a notification. It must be called once the app runs: from a window, an action, or a goroutine started after Run. A notification with the Tag of one that is shown replaces it. It is safe from any goroutine.
func Open ¶
Open opens another window. It is safe from event handlers and from goroutines: the window is opened on the UI thread. The returned ui.Window controls it; actions on it before the window exists run once it is open, and Closed reports whether it closed or failed to open. The app keeps running while the window is open (see Window.QuitWhenClosed).
func OpenDockWindow ¶
func OpenDockWindow(w ui.DockWindow) ui.Window
OpenDockWindow opens the window of a floating dock group with Open. It is the opener that ui.Dock.Floating takes:
ui.Dock(layout, panels).Floating(app.OpenDockWindow)
The window takes the group's title, position and size, and its close and geometry handlers are the dock's, so the layout records the window's place as it moves and when it closes, and the group's panels return to the dock when the window closes. A window that opens at a place off its monitor is moved in from the monitor's edges (on Windows). The window takes the dock window's theme, text, zoom and key bindings, and the actions it does not handle go on to the dock window (see the Docking section of docs/layout.md). It is not quit with the app's last window: the main window should set QuitWhenClosed, so that closing it closes the floating windows too.
func Quit ¶ added in v0.6.0
func Quit()
Quit closes every window and ends the app, so Run returns. The OnClose of each window is asked first, as for a QuitWhenClosed window; if one returns false, nothing closes and the app keeps running. A CloseToTray window closes rather than hides. It is safe from any goroutine; a call made before Run takes effect once the app starts.
func RegisterControl ¶ added in v0.6.2
func RegisterControl()
RegisterControl makes the control channel available in this program: with JAMB_CONTROL=1 in its environment, the app opens it at start (see docs/tools.md, "Control channel"). Package devtools calls it; an app does not need to.
func RegisterInspector ¶ added in v0.4.0
func RegisterInspector()
RegisterInspector makes the visual inspector available in this program: under `jamb dev`, with JAMB_INSPECT=1, and in an app that sets App.DevTools, the inspector opens. Package devtools calls it from its init, so an app that wants the inspector in a release build imports devtools and does not call it.
func RegisterScenes ¶ added in v0.6.4
func RegisterScenes(names func() []string, open func(name string) (func(*ui.Context) ui.Element, error))
RegisterScenes connects the app to the scenes that package scene holds, for JAMB_SCENE and the control channel's scene ops (see docs/tools.md, "Scenes"). Package devtools calls it; an app does not need to.
func RemoveNotification ¶
RemoveNotification removes the notification with the tag. A tag that is not shown is not an error.
Types ¶
type App ¶
type App struct {
// contains filtered or unexported fields
}
App is an application instance. A process has one App: its windows share the UI thread, the text system and the GPU device.
func (*App) AppID ¶
AppID sets the app's Application User Model ID, the identifier that Windows uses to group the app's windows on the taskbar, and to find its jump list, its Recent documents and its single instance. It is set when the app starts, before the first window opens. Use a stable identifier in the form CompanyName.ProductName, such as "JambExamples.Notes": it is letters, digits, '.', '-' and '_', starts with a letter or digit, and is at most 128 characters. Keep it the same across versions. A packaged (MSIX) app has an identity from its package, and the package's ID is used instead; see docs/os-integration.md, Jump lists and single instance section.
On Linux the AppID is the Wayland app ID of the app's windows (else the executable's name), which the desktop matches to a .desktop file of the same name, such as JambExamples.Notes.desktop, for the app's icon and name in the task manager. It also names the app's tray icons.
func (*App) DevTools ¶
DevTools turns the visual inspector on in a release build as well, for every window: Ctrl+Shift+I opens an inspector window for the window that has the focus, and closes it again. The inspector is on by default under `jamb dev` and with JAMB_INSPECT=1, and it shows the elements, styles, accessibility and frame timings of a window; see docs/tools.md, "Visual inspector".
The inspector is linked only into a program that imports package devtools. Without that import, DevTools(true) does nothing, and the program prints a warning once, to stderr, that says how to link it.
func (*App) FallbackFont ¶ added in v0.6.0
FallbackFont registers a font file (TrueType or OpenType data) for the characters that the font of a text lacks, for every window of the app: an emoji font, or a font for a script the app needs on every system, such as a CJK font. Fallback fonts are tried in the order they were registered, before the platform's own fallback fonts. A color font draws in color where jamb draws color glyphs (see docs/text.md).
app.New().FallbackFont(notoColorEmoji).Run(app.Window{...})
Like Font, the fonts are parsed while the first window opens, and data that is not a font makes RunE return an error.
func (*App) Font ¶
Font registers a font file (TrueType or OpenType data, such as a //go:embed file) as the upright face of family at weight, for every window of the app. Text uses it with Font(family) or Style.FontFamily; a weight the family has no face for uses the nearest one, and italic text uses the upright face. A family named like a built-in one ("" for the UI font, "mono") replaces that whole family: a weight the app gives no face for uses the nearest one the app gave, never the system's face. An app that replaces the UI font does not wait for the system's fonts when it starts.
app.New().
Font("Inter", ui.FontRegular, interRegular).
Font("Inter", ui.FontBold, interBold).
Run(app.Window{...})
The fonts are parsed while the first window opens. Data that is not a font makes RunE return an error, and Run print it and exit.
Example ¶
Fonts are registered before Run, and apply to every window of the app.
package main
import (
"github.com/tyler-builds/jamb/app"
"github.com/tyler-builds/jamb/ui"
)
func main() {
var interRegular, interBold []byte // the font files, for example from go:embed
app.New().
Font("Inter", ui.FontRegular, interRegular).
Font("Inter", ui.FontBold, interBold).
Run(app.Window{Title: "Fonts", Width: 640, Height: 480,
Root: func(ctx *ui.Context) ui.Element { return ui.Text("Fonts") }})
}
Output:
func (*App) JumpList ¶
JumpList sets the app's jump list, which is committed when the app starts. It needs an AppID. Each task starts the program's executable, and a program run with go run has an executable that is removed when the run ends, so its tasks stop working then. See the Jump lists and single instance section of docs/os-integration.md.
func (*App) KeepRunning ¶ added in v0.6.0
KeepRunning keeps the app running after its last window closes, until Quit is called or a QuitWhenClosed window closes. It suits an app that lives in the notification area, or that opens a window again on a single instance handoff or a notification click. Such an app must offer a way to quit, such as a Quit item in its tray menu, since without a window the user may have no other.
func (*App) OnNotification ¶
func (a *App) OnNotification(fn func(n NotificationActivation)) *App
OnNotification sets the function that is called on the UI thread when the user clicks a notification that the app sent, on the body or on a button. It needs SingleInstance and an AppID: a click on a notification starts the app's program with the click's data, and SingleInstance hands that to the running app, which then calls fn in place of starting a second window. A click after the app has closed starts the app and calls fn once its window is open.
The data of a click is passed through the notification system, which any program of the user can also send. fn must treat Action, Tag and Args as input from outside the app, and check them before it acts on them.
func (*App) Run ¶
Run opens the window and blocks until the app quits: when the last window closes (unless KeepRunning is set), when a QuitWhenClosed window closes, or when Quit is called. With KeepRunning, a Window with no Root, such as app.Window{}, starts the app with no window (see RunE). On failure it prints the error and exits with status 1. Use RunE to handle errors yourself. A later launch of a SingleInstance app returns at once, without a window, after its command line has been handed to the running app.
func (*App) RunE ¶
RunE is Run returning an error instead of exiting. Call it once per process: a later call returns an error at once. An app that shows windows one after another, such as a setup window and then a settings window from a tray icon, runs once with KeepRunning and opens the later windows with Open.
With KeepRunning, w may have no Root, such as app.Window{}: the app starts with no window, as a tray app launched at login does, and opens its windows with Open. Such an app must show a way to quit, such as a tray icon with a Quit item.
func (*App) SingleInstance ¶
SingleInstance makes the app a single instance per user and session. A later launch hands its command line to the first instance and exits with status 0, without opening a window. The first instance calls onArgs on its UI thread with the arguments after the program name, as os.Args[1:] gives them, and the working directory of the later launch, so a relative path can be resolved with filepath.Join(dir, arg). Before onArgs runs, the first instance's first window is brought to the front. onArgs may be nil.
The first launch keeps its own arguments in os.Args, as usual. SingleInstance needs an AppID, which names the instance. A later launch whose hand-off fails runs on its own, with its own window and state. It does not depend on JumpList: a jump list task starts a new process, and a single instance app receives that process's arguments through its hand-off.
type Changes ¶ added in v0.6.2
type Changes struct {
// Name is what is unsaved, as the prompt names it: a document's name, such
// as "Report.txt", or a count, such as "3 notes". Empty asks about "your
// changes".
Name string
// Save saves the changes and returns nil when they are saved. It runs on a
// goroutine of its own, so the window keeps drawing and the prompt shows
// that it is saving; signals are safe to read there (use Peek). A nil Save
// means the changes cannot be saved, and the prompt offers only to discard
// them.
Save func() error
}
Changes describes work in a window that closing the window would lose. A Window's Unsaved returns it (see Window.Unsaved).
type Chrome ¶
type Chrome uint8
Chrome selects who draws a window's title bar.
const ( // ChromeNative keeps the operating system's title bar and frame. ChromeNative Chrome = iota // ChromeCustom removes the operating system's title bar, and the app // draws its own. The window keeps its native resize borders, Aero Snap, // shadow and maximize behavior. The app marks its drag and button areas // with ui.DivElement.WindowArea; ui.TitleBarButtons draws the usual // buttons. ChromeCustom )
type Corners ¶ added in v0.7.0
type Corners uint8
Corners selects how a window's corners are drawn. The system draws them where it draws the window's frame: Windows 11 and macOS round every window, and on Linux a desktop that draws frames (KDE) rounds them as its theme says. On a desktop that leaves the frame to the app (GNOME), jamb draws the corners, a shadow and a thin outline itself. Corners are square while the window is maximized, fullscreen or snapped against that edge. Windows 10 does not round windows, so there every choice is square.
const ( // CornersDefault is the system's choice: rounded on Windows 11, macOS and // GNOME (as GNOME's own windows are). CornersDefault Corners = iota // CornersRound rounds the corners as the system rounds a main window. CornersRound // CornersRoundSmall rounds them less, as Windows 11 rounds menus and // tooltips. CornersRoundSmall // CornersSquare keeps them square. CornersSquare )
type JumpList ¶
type JumpList struct {
// Tasks are listed under Tasks, in order. Windows may show only the first few.
Tasks []JumpTask
// Recent shows the Recent category, which lists the documents given to
// AddRecentDocument.
Recent bool
}
JumpList is the app's Windows jump list: the tasks in its taskbar menu, and whether the menu has a Recent category. The app sets it with JumpList, when it starts, under its AppID. Nothing is listed unless the app sets it, and the framework adds no tasks of its own.
Each task starts the app's own executable with Args, as a new process. Without SingleInstance, that process opens its own window and keeps its own state. With SingleInstance, the new process hands its command line to the running app, which receives it in onArgs. Use SingleInstance when a task should act in the running app, such as opening a window in it, rather than start another one.
type JumpTask ¶
type JumpTask struct {
// Title is the text the menu shows. It is required.
Title string
// Args is the command line after the executable, such as "--new-note". Windows
// takes it as one string, so an argument with spaces needs quotes, as in a
// shell.
Args string
// Description is shown as the tooltip of the task.
Description string
// Icon is an optional path and icon index, as "path,index", such as
// "C:\\app\\icons.dll,2". A comma followed by a number is read as the index;
// otherwise the whole string is the path, with index 0. Empty uses the
// executable's own icon.
Icon string
}
JumpTask is one task of a JumpList.
type Notification ¶
type Notification struct {
// Title is the first line, in bold. It is required.
Title string
// Body is the text below the title. It may be empty.
Body string
// Image is shown as a hero image: a banner above the text, which Windows scales
// to fit the notification. It is saved as a PNG file in the temporary folder, as
// Windows reads images from files; the file is named by a digest of its contents,
// so the same image is saved once.
Image image.Image
// Actions are the buttons, in order: at most five. A click on a button reports
// the button's ID to OnNotification as NotificationActivation.Action.
Actions []NotificationAction
// Tag identifies the notification. A later notification with the same tag
// replaces the one that is shown, and RemoveNotification removes it. It is at
// most 64 characters, and empty for none.
Tag string
// Args is returned unchanged to OnNotification as NotificationActivation.Args
// when the notification is activated. Put an ID or a short string in it, not a
// secret: it is stored in the notification's activation data.
Args string
// Silent shows the notification without its sound.
Silent bool
}
Notification is an operating system notification: a Windows toast, shown in the Notification Center. Notify shows it; see the OS notifications section of docs/os-integration.md.
Write Title and Body as complete sentences. Windows reads them aloud with screen readers, so "3 warnings in the build" is read as written, and "3 warnings" alone is not a sentence a listener can place.
type NotificationAction ¶
type NotificationAction struct {
// ID is what OnNotification receives when the button is clicked. It is required
// and unique within the notification.
ID string
// Label is the text of the button. It is required.
Label string
}
NotificationAction is a button of a Notification.
type NotificationActivation ¶
type NotificationActivation struct {
// Action is the ID of the button that was clicked, or empty for a click on the
// body of the notification.
Action string
// Tag and Args are the Tag and Args of the notification.
Tag string
// Args is the Args of the notification, as Tag describes.
Args string
}
NotificationActivation is a click on a notification, reported to OnNotification.
type Tray ¶
type Tray struct {
// contains filtered or unexported fields
}
Tray is a notification area icon: the icon at the edge of the taskbar, which the user can click and right click. Make one with NewTray and add it with Show.
The methods are safe from any goroutine. They run on the UI thread in the order they are called, so a call before the app runs waits for it to start.
On Linux the icon is a StatusNotifierItem, which KDE Plasma and most panels show, and GNOME with the AppIndicator extension; see docs/os-integration.md.
A tray icon needs no window. On Windows the icon, its tooltip and its menu are Windows' own: the menu follows the system theme, and assistive technology reads it as the system's menus. Windows keeps the user's choice to show or hide an icon by its identity: with an AppID, the identity is derived from the AppID and the icon's place in the order of NewTray calls, so keep that order from run to run. Windows also ties that identity to the executable's path, and an icon whose executable moved is added by its ID instead.
func NewTray ¶
func NewTray(o TrayOptions) *Tray
NewTray returns a notification area icon. It is not shown until Show is called.
func (*Tray) Hide ¶
func (t *Tray) Hide()
Hide takes the icon out of the notification area, and Show adds it again. An app's icons are also removed when the app quits. It is safe from any goroutine.
func (*Tray) SetIcon ¶
SetIcon sets the image of the icon; nil is the executable's icon. It is safe from any goroutine.
func (*Tray) SetTooltip ¶
SetTooltip sets the tooltip of the icon. It is safe from any goroutine.
func (*Tray) Show ¶
func (t *Tray) Show()
Show adds the icon to the notification area. Showing an icon that is shown does nothing. A failure, such as a refused icon, is printed, and the icon is not shown; Show may be called again. It is safe from any goroutine.
func (*Tray) Shown ¶ added in v0.2.0
Shown reports whether the icon is in the notification area: Show has added it, and Hide has not taken it out. An icon stays shown when Explorer restarts, as it is added to the new notification area again. It is safe from any goroutine: from another goroutine, it waits for the UI thread to run the calls made before it, and it reports false once the app has quit.
type TrayItem ¶
type TrayItem struct {
// Label is the text of the item.
Label string
// Disabled shows the item, but it cannot be chosen.
Disabled bool
// Checked shows a check mark beside the label.
Checked bool
Submenu []TrayItem
// OnClick runs when the item is chosen.
OnClick func()
// contains filtered or unexported fields
}
TrayItem is an item of a tray menu. A tray menu is the system's native menu (on Linux, the panel's, through dbusmenu), so it is a subset of what the menus of ui can show: an item has a label, a disabled state, a check mark and a submenu, but no icon, shortcut or action. Its OnClick runs on the UI thread after the menu closes, when the user chooses the item. A separator is made by TraySeparator.
func TraySeparator ¶
func TraySeparator() TrayItem
TraySeparator returns a rule between groups of menu items.
type TrayOptions ¶
type TrayOptions struct {
// Icon is the image of the icon, drawn at the small icon size of the current
// DPI. Nil uses the executable's icon, which jamb package embeds, or the
// standard application icon when the executable has none.
Icon image.Image
// Tooltip is the text shown when the pointer rests on the icon. Windows shows
// at most 127 UTF-16 units of it.
Tooltip string
// OnClick runs on the UI thread for a click, and for Enter or Space when the
// icon has the keyboard focus. A double click runs OnClick for its first click,
// as Windows reports both, and then OnDoubleClick. An app that wants different
// actions for the two should make OnClick idempotent, or rely on OnDoubleClick
// alone and leave OnClick nil.
OnClick func()
// OnDoubleClick runs on the UI thread for a double click.
OnDoubleClick func()
// Menu returns the menu, which is shown on a right click, and with the context
// menu key or Shift+F10. It runs on the UI thread each time the menu opens, so
// its checked items show the app's state. Nil means the icon has no menu.
Menu func() []TrayItem
}
TrayOptions describes a notification area icon; see NewTray.
type Window ¶
type Window struct {
// Title is the title of the window, which its title bar and taskbar button show.
Title string
Width int // logical pixels; default 1024
Height int // logical pixels; default 720
// Icon is the window's icon on Windows: in its title bar, on its taskbar
// button and thumbnail, and in Alt+Tab. It is drawn from the image at each
// size Windows shows, for the window's DPI. Nil uses the executable's icon,
// which jamb package embeds, so a packaged app needs no Icon; a program built
// without an icon keeps the one Windows gives it. Other platforms ignore it.
// Give an image of 256 pixels or more, so that no size is scaled up.
Icon image.Image
// MinWidth is the smallest width that the user can resize the window to, in logical pixels.
MinWidth int
// MinHeight is the smallest height that the user can resize the window to, in logical pixels.
MinHeight int
// Theme pins the window to one theme. Without it, the window follows the
// system's app mode (light or dark), live: it uses DarkTheme while Windows
// is in dark mode and LightTheme otherwise, by default ui.DarkTheme() and
// ui.LightTheme(). ctx.SetTheme also pins one theme.
Theme *ui.Theme
// LightTheme is the theme used in light mode; by default it is ui.LightTheme().
LightTheme *ui.Theme
// DarkTheme is the theme used in dark mode; by default it is ui.DarkTheme().
DarkTheme *ui.Theme
// Strings is the text that the built-in controls show and announce. Without it,
// the window uses the display language of Windows (see ui.SystemStrings), and
// English where that language has no translation or cannot be read. Give
// ui.StringsFor(tag) to choose a language, or start from ui.EnglishStrings() and
// set the messages to change. A field left empty shows English (see ui.Strings).
Strings *ui.Strings
// Root renders the whole window. It is a component: it re-runs when a
// signal it reads changes.
Root func(ctx *ui.Context) ui.Element
// Zoom is the initial UI zoom (0 = 100%). Users change it with Ctrl+=,
// Ctrl+-, Ctrl+0 and Ctrl+wheel; OnZoom is called after each change so
// the app can remember it.
Zoom float32
// OnZoom is called after each change of the zoom, with the new zoom.
OnZoom func(zoom float32)
// Bindings maps keys to actions for the whole window; see ui.Bind.
Bindings []ui.Binding
// KeymapFile is a JSON keymap whose bindings come after Bindings, so they
// override them; see keymap.Parse. A missing file is fine. The file is
// reloaded when it changes, and the app keeps running with the bindings it
// had if the change does not parse. Problems are printed to stderr, and
// the valid bindings still apply. Actions lists the actions the file may
// name.
KeymapFile string
// Actions lists the actions that KeymapFile may name.
Actions []*ui.Action
// OnKeymapLoad is called on the UI thread after the startup load and after
// each reload that changed the bindings, with nil on success or the
// problems. Use it to show errors in the app.
OnKeymapLoad func(err error)
// Chrome selects who draws the title bar: the operating system (the
// default) or the app; see ChromeCustom.
Chrome Chrome
// Corners selects how the window's corners are drawn: the system's
// default (the zero value), rounded, slightly rounded or square. See
// Corners.
Corners Corners
// X and Y place the window's top-left corner in logical screen pixels.
// Both zero centers the first window, and cascades a later one 32 pixels
// from the last window opened.
X, Y int
// OnClose is called when the window is asked to close, by the user, by Close on
// the ui.Window that Open returns, or by the app. Return false to keep the window
// open, for example to ask about unsaved changes first.
OnClose func() bool
// Unsaved reports the work in the window that closing it would lose, or nil
// when there is none. When the window is about to close, or the app to quit,
// and every OnClose has let it, a window that reports changes asks the user
// first: Save, Don't save or Cancel, in a dialog over the window. Nothing
// closes until every window is answered, and Cancel keeps them all open.
// It is called on the UI thread. See Changes, and docs/windows.md.
Unsaved func() *Changes
// OnClosed is called on the UI thread after the window has closed, or
// after Open failed to open it.
OnClosed func()
// OnGeometry is called on the UI thread as the window is moved, resized or
// given another scale, with its position and content size in logical pixels,
// as X, Y, Width and Height are. It is called for each step of a move or a
// resize, so an app that saves the geometry should wait until it is still.
OnGeometry func(x, y, width, height int)
// QuitWhenClosed quits the app when this window closes, even while other
// windows are open. Before it closes, the OnClose of every other window is
// asked; if one returns false, nothing closes. Then the other windows close
// too, each without being asked again. By default the app quits when the last
// window closes.
QuitWhenClosed bool
// CloseToTray, while it holds true, hides the window when the user closes it,
// instead of closing it, and the app keeps running. The window's taskbar button
// goes with it. Show (ui.Window's Show) brings the window back, which a tray
// icon's OnClick does for a window the user hid. The app owns the signal, so it
// can offer the choice as a setting: a Switch bound to the signal takes effect at
// the next close. The window hides only while one of the app's tray icons is
// shown, since without one the user could not show it again; otherwise it closes
// as usual. OnClose is not asked while the window hides, and the window handle's
// Close still closes the window, asking OnClose as usual. Nil is false.
CloseToTray *ui.Signal[bool]
// contains filtered or unexported fields
}
Window describes an application window and its content.
Source Files
¶
- app.go
- backend_linux.go
- control.go
- control_clock.go
- control_commands.go
- control_ops.go
- control_unix.go
- dev.go
- dock.go
- fileicon.go
- fileicon_other.go
- frame.go
- framestats.go
- gcpause.go
- gpu_linux.go
- headless.go
- heaplog.go
- identity.go
- inspect.go
- inspect_window.go
- instance.go
- jumplist.go
- notification.go
- notification_linux.go
- quit.go
- recovery.go
- scene.go
- settings.go
- shell_other.go
- taskbar.go
- tray.go
- tray_linux.go
- visible.go
- window.go