Documentation
¶
Overview ¶
Package desktop holds what only desktops have: the window, its title bar and the menus, as NSH's nsh/desktop. It builds on every platform, so one app runs everywhere: on phones and tablets its functions do nothing, and IsAvailable says whether they act.
A title bar of the app's own calls SetTitleBar once, marks its background with core.View's Desktop.WindowDrag and keeps clear of the edges TitleBar reports; SetWindowControls moves or hides the system's controls in it. A window over a material leaves transparent what should show it while ShowsMaterial.
Index ¶
- Constants
- func AddRecentFile(cx *core.Scope, path string)
- func CanLookUp(cx *core.Scope) bool
- func CanMakeWindowsTransparent(cx *core.Scope) bool
- func CanPlaceWindows(cx *core.Scope) bool
- func CanReadFrontmostApp(cx *core.Scope) bool
- func CanSetWindowLevel(cx *core.Scope) bool
- func CanSetWindowWorkspaces(cx *core.Scope) bool
- func CanSkipTaskbar(cx *core.Scope) bool
- func ClearRecentFiles(cx *core.Scope)
- func CloseWindow(cx *core.Scope)
- func FullScreen(cx *core.Scope) bool
- func GuidePermission(cx *core.Scope, p core.Permission, opts GuideOptions, ...) (stop func())
- func IsAvailable(cx *core.Scope) bool
- func LaunchAtLogin(cx *core.Scope, done func(on bool))
- func LaunchedAtLogin(cx *core.Scope) bool
- func LookUp(cx *core.Scope, text string, in *core.Ref, at core.Bounds) bool
- func Maximized(cx *core.Scope) bool
- func MinimizeWindow(cx *core.Scope)
- func Minimized(cx *core.Scope) bool
- func OnOpenFiles(cx *core.Scope, fn func(paths []string))
- func OnOpenLinks(cx *core.Scope, fn func(links []string))
- func OnQuitRequest(cx *core.Scope, fn func(q *QuitRequest))
- func OnReopen(cx *core.Scope, fn func())
- func OrderFront(cx *core.Scope)
- func PopupMenu(cx *core.Scope, items []MenuItem, at core.Point, closed func())
- func Restart(cx *core.Scope)
- func RevealFile(cx *core.Scope, path string, done func(error))
- func SetApplicationMenu(cx *core.Scope, items []MenuItem)
- func SetDockMenu(cx *core.Scope, items []MenuItem)
- func SetDockVisible(cx *core.Scope, on bool)
- func SetLaunchAtLogin(cx *core.Scope, on bool)
- func SetMainWindow(cx *core.Scope, w *Window)
- func SetMenuBar(cx *core.Scope, mode MenuBarMode)
- func SetShutdownMode(cx *core.Scope, mode ShutdownMode)
- func SetSkipTaskbar(cx *core.Scope, on bool)
- func SetTitle(cx *core.Scope, title string)
- func SetTitleBar(cx *core.Scope, style TitleBarStyle, height core.Points)
- func SetWindowConstraints(cx *core.Scope, c WindowConstraints)
- func SetWindowControls(cx *core.Scope, c WindowControls)
- func SetWindowFrame(cx *core.Scope, f WindowFrame)
- func SetWindowLevel(cx *core.Scope, level WindowLevel)
- func SetWindowMaterial(cx *core.Scope, m WindowMaterial)
- func SetWindowPointerEvents(cx *core.Scope, p WindowPointerEvents)
- func SetWindowShadow(cx *core.Scope, on bool)
- func SetWindowTransparent(cx *core.Scope, on bool)
- func SetWindowWorkspaces(cx *core.Scope, w WindowWorkspaces)
- func ShowsMaterial(cx *core.Scope) bool
- func TitleBar(cx *core.Scope) core.Edges
- func ToggleFullScreen(cx *core.Scope)
- func ToggleMaximize(cx *core.Scope)
- func Transparent(cx *core.Scope) bool
- func TrashFile(cx *core.Scope, path string, done func(trashedAt string, err error))
- type FrontmostAppInfo
- type GuideOptions
- type HotKey
- type HotKeyState
- type MenuBarMode
- type MenuItem
- type MenuRole
- type PanelOptions
- type QuitRequest
- type ShutdownMode
- type TitleBarStyle
- type Tray
- type TrayOptions
- type Window
- type WindowClosing
- type WindowConstraints
- type WindowControls
- type WindowFrame
- type WindowLevel
- type WindowMaterial
- type WindowOptions
- type WindowPointerEvents
- type WindowWorkspaces
Constants ¶
const ( ShutdownOnLastWindowClose = core.ShutdownOnLastWindowClose ShutdownOnMainWindowClose = core.ShutdownOnMainWindowClose ShutdownOnExplicit = core.ShutdownOnExplicit )
const ( // HotKeyPending waits for the platform's answer. HotKeyPending = core.HotKeyPending // HotKeyRegistered is a shortcut the platform fires. HotKeyRegistered = core.HotKeyRegistered // HotKeyTaken is a combination another registration holds: the app's own, or another app's on Windows and X11; on macOS another app's only when it registered exclusively; on Wayland one the compositor or the user did not bind. HotKeyTaken = core.HotKeyTaken // HotKeyUnsupported is a key the platform cannot make a global shortcut, or a platform or session with none. HotKeyUnsupported = core.HotKeyUnsupported )
const ( TitleBarDefault = core.TitleBarDefault TitleBarHidden = core.TitleBarHidden )
const ( WindowLevelNormal = core.WindowLevelNormal WindowLevelFloating = core.WindowLevelFloating WindowLevelDesktop = core.WindowLevelDesktop )
const ( // WindowWorkspacesCurrent keeps a window on the workspace it opened on. WindowWorkspacesCurrent = core.WindowWorkspacesCurrent // WindowWorkspacesAll shows it on every workspace. WindowWorkspacesAll = core.WindowWorkspacesAll )
const ( // WindowPointerAuto takes the pointer everywhere in the window, as windows do. WindowPointerAuto = core.WindowPointerAuto // WindowPointerNone lets every press, scroll and hover through to what is below, as a heads-up display does. WindowPointerNone = core.WindowPointerNone // WindowPointerPainted takes the pointer only over the views that draw something, such as a background, a border, a text or an image, or that hear it, such as a pressable, a context menu or a window drag handle; elsewhere it goes through, as around a desktop pet. WindowPointerPainted = core.WindowPointerPainted )
const ( MenuBarShown = core.MenuBarShown MenuBarAutoHide = core.MenuBarAutoHide )
const ( WindowMaterialNone = core.WindowMaterialNone // The materials of window areas. WindowMaterialWindow = core.WindowMaterialWindow WindowMaterialContent = core.WindowMaterialContent WindowMaterialSidebar = core.WindowMaterialSidebar WindowMaterialHeader = core.WindowMaterialHeader WindowMaterialTitlebar = core.WindowMaterialTitlebar WindowMaterialUnderWindow = core.WindowMaterialUnderWindow WindowMaterialUnderPage = core.WindowMaterialUnderPage // The materials of transient surfaces, Acrylic on Windows. WindowMaterialMenu = core.WindowMaterialMenu WindowMaterialPopover = core.WindowMaterialPopover WindowMaterialHUD = core.WindowMaterialHUD WindowMaterialSheet = core.WindowMaterialSheet WindowMaterialTooltip = core.WindowMaterialTooltip WindowMaterialSelection = core.WindowMaterialSelection WindowMaterialFullScreenUI = core.WindowMaterialFullScreenUI // Windows 11's system backdrops: Mica, Acrylic and Mica Alt. WindowMaterialMica = core.WindowMaterialMica WindowMaterialAcrylic = core.WindowMaterialAcrylic WindowMaterialTabbed = core.WindowMaterialTabbed )
const ( MenuRoleNone = core.MenuRoleNone MenuAbout = core.MenuAbout MenuHide = core.MenuHide MenuHideOthers = core.MenuHideOthers MenuShowAll = core.MenuShowAll MenuQuit = core.MenuQuit MenuUndo = core.MenuUndo MenuRedo = core.MenuRedo MenuCut = core.MenuCut MenuCopy = core.MenuCopy MenuPaste = core.MenuPaste MenuSelectAll = core.MenuSelectAll MenuMinimize = core.MenuMinimize MenuZoom = core.MenuZoom MenuToggleFullScreen = core.MenuToggleFullScreen MenuClose = core.MenuClose MenuPasteAndMatchStyle = core.MenuPasteAndMatchStyle MenuDelete = core.MenuDelete MenuStartSpeaking = core.MenuStartSpeaking MenuStopSpeaking = core.MenuStopSpeaking MenuBringAllToFront = core.MenuBringAllToFront MenuServices = core.MenuServices MenuWindowMenu = core.MenuWindowMenu MenuHelpMenu = core.MenuHelpMenu )
Variables ¶
This section is empty.
Functions ¶
func AddRecentFile ¶ added in v0.2.0
AddRecentFile records path as a document the user opened, which the system offers again: in the Dock menu and File › Open Recent on macOS, for the types nsgo.yaml's file_types declares, and in the Recent category of the Jump List on Windows, for the types the app is registered to open. Choosing one reaches OnOpenFiles. Elsewhere it does nothing.
func CanLookUp ¶ added in v0.2.0
CanLookUp reports whether LookUp shows the system's dictionary panel: in a window on macOS. Windows, Linux and the web have no such panel, so it is false there, as for the app's own scope and a tray icon's, which show in no window.
func CanMakeWindowsTransparent ¶ added in v0.2.0
CanMakeWindowsTransparent reports whether the scope's window shows what is behind it while transparent: on macOS; on Windows in a window opened transparent where DirectComposition draws it, the only one SetWindowTransparent changes; on Linux where the display composites with an RGBA visual, as Wayland always does and X11 with a compositing manager. It is false elsewhere, where a transparent window stays opaque, and for a view a host embeds, the app's own scope, a panel or a tray icon, which show in no window of their own. It is what the window could do, not what it does: Transparent says whether the window or a transparent panel draws nothing of its own now.
func CanPlaceWindows ¶ added in v0.2.0
CanPlaceWindows reports whether SetWindowFrame moves the scope's window to the position it gives: on macOS and Windows, and for an Android overlay (mobile.OpenOverlay), which it keeps on the screen, but not for a view a host embeds, the app's own scope or a tray icon's, which show in no window, or on Linux.
func CanReadFrontmostApp ¶ added in v0.2.0
CanReadFrontmostApp reports whether FrontmostApp follows the application in front, tracked: on macOS, Windows and Linux on X11, but not on Wayland, which has no portable way to tell, on phones, the web or mini programs, or for code whose Access refuses core.AccessFrontmostApp, as it says what else the user runs.
func CanSetWindowLevel ¶ added in v0.2.0
CanSetWindowLevel reports whether SetWindowLevel stacks the scope's window: on macOS, Windows and Linux on X11, but not for a view a host embeds, the app's own scope or a tray icon's, which show in no window, a Linux panel no window manager manages, or on Wayland.
func CanSetWindowWorkspaces ¶ added in v0.2.0
CanSetWindowWorkspaces reports whether SetWindowWorkspaces puts the scope's window on the workspaces it names: on macOS, and on Linux on X11 where the window manager lists _NET_WM_DESKTOP among the hints it supports (_NET_SUPPORTED), as it says when the window opens. It is false on Windows, on Wayland, on phones and the web, and for a view a host embeds, the app's own scope or a tray icon's, which show in no window, or a Linux panel no window manager manages.
func CanSkipTaskbar ¶ added in v0.2.0
CanSkipTaskbar reports whether SkipTaskbar and SetSkipTaskbar keep the scope's window off the taskbar: on Windows, on Linux under X11, and on macOS, where they keep it out of the Window menu and Cmd+` and SetDockVisible is the Dock's. Wayland has no way for an app to, and it is false there, on phones and the web, and for a view a host embeds, the app's own scope, a panel or a tray icon.
func ClearRecentFiles ¶ added in v0.2.0
ClearRecentFiles forgets the documents AddRecentFile recorded, the app's alone.
func CloseWindow ¶
CloseWindow closes the window as its close button does: the window's OnClosing handlers may keep it, and the app ends by its shutdown mode.
func FullScreen ¶
FullScreen reports whether the window is in full screen.
func GuidePermission ¶
func GuidePermission(cx *core.Scope, p core.Permission, opts GuideOptions, done func(core.PermissionStatus)) (stop func())
GuidePermission opens the page of the system's settings that gives p and waits for the user to give it. On macOS, for the panes whose list takes an app dragged into it (all but the microphone's, the camera's, the calendars' and the reminders'), a panel under System Settings' window follows it, never takes the focus, and holds the app for the user to drag into the list. It ends, and done hears the status then, once the app has p, the user closes the panel or System Settings, stop is called or the current owner goes; one guide shows at a time, and a new one ends the one before. On Windows it opens the microphone's or the camera's page and ends once the app has p or Settings closes. Where nothing guides, as on Linux and off desktops, done hears the status at once.
func IsAvailable ¶
IsAvailable reports whether the app runs on macOS, Windows or Linux, where this package's functions act.
func LaunchAtLogin ¶
LaunchAtLogin calls done with whether the system starts the app at login: false where SetLaunchAtLogin cannot register it, and on Windows also while the user has the app turned off in Startup apps.
func LaunchedAtLogin ¶ added in v0.2.0
LaunchedAtLogin reports whether the system started this run as a login item, as a tray app reads it to open no window then. It is known when the app's function first runs and stays the same for the run, reopens included; a restart (Restart) reports false. macOS reads the launch Apple event, or the LaunchAgent's marker on macOS 11 and 12, and Windows and Linux the marker their login entries start the app with; phones and the web report false. Tests set it with nsgotest.Environment(core.Environment{LaunchedAtLogin: true}).
func LookUp ¶ added in v0.2.0
LookUp shows the system's dictionary panel for text, as a three-finger tap or Ctrl-Cmd-D does on macOS, with the text drawn over at, a box in the view in refers to (the surface's when in is nil), such as a TextSelection's Text and Bounds with its Selectable view's Ref. It reports whether the panel was asked for: false for blank text, an in that is not mounted, where CanLookUp is false, and for a confined view the user is not using (core.Scope.Confine).
func Maximized ¶
Maximized reports whether the window is maximized or zoomed, so a maximize button of the app's own can show restore.
func Minimized ¶
Minimized reports whether the window is minimized, so an app can stop work the user cannot see and resume it once the window is restored. It is always false on phones and the web, and on Wayland, which reports no minimized state.
func OnOpenFiles ¶
OnOpenFiles runs fn with the paths of files the system asks the app to open: the file types nsgo.yaml's file_types declares, opened from the Finder, the Dock or Open With, and on Windows and Linux the files named on the command line. Files the app launched to open wait for the first handler.
func OnOpenLinks ¶ added in v0.2.0
OnOpenLinks runs fn with links of the app's own URL schemes, which nsgo.yaml's url_schemes declares, that the system asks the app to open: clicked in a browser or another app, or opened with the open command. On macOS they reach the running app, and the link the app launched to open waits for the first handler. A link carries whatever the page that made it chose, so treat its contents as untrusted input and confirm with the user before acting on it.
func OnQuitRequest ¶
func OnQuitRequest(cx *core.Scope, fn func(q *QuitRequest))
OnQuitRequest runs fn when the user asks the app to quit, by Cmd+Q, the Dock, a tray menu's Quit or the system, on macOS, newest first: a handler may cancel the quit, or defer it with QuitRequest.Defer while it asks the user, and when none does the app quits. core.Scope.Quit and Restart quit without asking:
desktop.OnQuitRequest(cx, func(q *desktop.QuitRequest) {
if !dirty.Get() {
return
}
done := q.Defer()
base.ShowAlertDialog(cx, discard, func(label string) { done(label == "Discard") })
})
func OnReopen ¶
OnReopen runs fn when the user opens the app again while it runs: by clicking it in the Dock or launching it a second time. Without a handler the main window shows and takes the focus.
func OrderFront ¶
OrderFront shows the window, restoring it when minimized or hidden, brings it to the front of its level and activates the app.
func PopupMenu ¶
PopupMenu shows items as the platform's own context menu, its top left corner at at, in the points of the root view, as a press's or OnContextMenu's PagePosition. closed, when not nil, runs once it closes, after the OnSelect of an item chosen. A menu shown before closes first. Desktops show it; elsewhere closed runs at once.
func Restart ¶
Restart ends the app as core.Scope.Quit does, and nsgo.Run starts it again with the arguments it started with once it has exited, on macOS, Windows and Linux, so a setting read at launch takes effect. Under nsgo dev, and in a view a host embeds, it only quits.
func RevealFile ¶
RevealFile opens the file manager with path selected.
func SetApplicationMenu ¶
SetApplicationMenu replaces the application menu: macOS's menu bar, the window's menu bar on Windows and Linux. nil restores the platform's default. The items' handlers run under the current owner; when it goes, the default menu comes back.
func SetDockMenu ¶ added in v0.2.0
SetDockMenu sets the items the app's icon offers above the system's own, nil none: the menu of its Dock icon on macOS, with submenus, separators, check marks and disabled items as the application menu has them, and the Tasks of its Jump List on Windows, its taskbar button's and Start menu entry's. The items' handlers run under the current owner; when it goes, the items go too. The app has one such menu, the one any window set last.
A Jump List task is a top-level enabled item with a label and an OnSelect; submenus, separators and check marks are left out. Windows keeps the list while the app is not running: a task starts the app again, which hands the task to the copy already running when nsgo.yaml gives the app an id, and the item labeled as the task runs once the app has set its menu. Elsewhere it does nothing.
func SetDockVisible ¶
SetDockVisible shows the app in the Dock and the app switcher, or leaves it to its tray icon and windows, on macOS; nsgo.HideDock starts it hidden.
func SetLaunchAtLogin ¶
SetLaunchAtLogin has the system start the app as the user logs in, or no more. macOS takes only an app in a bundle, as nsgo build makes it: SMAppService registers it on macOS 13 and later, and a per-user LaunchAgent, which takes effect at the next login, on macOS 11 and 12. Windows writes the user's Run key and Linux an XDG autostart entry; an MSIX, Flatpak or Snap package cannot start at login yet. A failure is logged.
func SetMainWindow ¶
SetMainWindow makes w the main window: the one ShutdownOnMainWindowClose follows and reopening the app shows. The window nsgo.SetMainView opens is main.
func SetMenuBar ¶
func SetMenuBar(cx *core.Scope, mode MenuBarMode)
SetMenuBar says when Windows and Linux show the menu bar the window draws for the application menu, which a window with a hidden title bar has none of (SetTitleBar); macOS's is the system's and always shows.
func SetShutdownMode ¶
func SetShutdownMode(cx *core.Scope, mode ShutdownMode)
SetShutdownMode says when the app ends by itself: as its last window closes (the default), as its main window closes, or only by core.Scope.Quit, as a tray app does.
func SetSkipTaskbar ¶ added in v0.2.0
SetSkipTaskbar keeps the window off the Windows taskbar and Alt+Tab, off the task list on X11, and out of macOS's Window menu and Cmd+`, or puts it back; WindowOptions.SkipTaskbar and nsgo.SkipTaskbar open a window so. On macOS the Dock shows the app rather than its windows, and SetDockVisible takes it out. CanSkipTaskbar says whether it takes effect.
func SetTitleBar ¶
func SetTitleBar(cx *core.Scope, style TitleBarStyle, height core.Points)
SetTitleBar hides the system's title bar so the app can draw its own height points tall (0: the platform's height), or restores it. The platform centers its window controls in that height. TitleBar then reports the area they keep. A window with a hidden title bar has no menu bar on Windows and Linux; on Windows, Alt and F10 open the application menu as a popup from the window's top corner instead, and Alt with a top-level item's first letter opens that item's menu.
func SetWindowConstraints ¶
func SetWindowConstraints(cx *core.Scope, c WindowConstraints)
SetWindowConstraints limits the window's content size and says whether it resizes, minimizes and maximizes; the zero WindowConstraints limits nothing. The window moves into its new sizes, and MinimizeWindow and ToggleMaximize do nothing where it may not, as its buttons:
desktop.SetWindowConstraints(cx, desktop.WindowConstraints{MinWidth: 480, MinHeight: 320, NoMaximize: true})
A window sets them as it opens with WindowOptions.Constraints, and the main window with nsgo.WindowConstraints. On Linux, GTK 4 has neither maximum sizes nor a way to take the title bar's buttons, so only NoResize, or a maximum equal to the minimum, limits a window from above, and the user's buttons stay.
func SetWindowControls ¶
func SetWindowControls(cx *core.Scope, c WindowControls)
SetWindowControls hides the system's window controls in a hidden title bar, or moves macOS's traffic lights in it, from any time on:
desktop.SetWindowControls(cx, desktop.WindowControls{TrafficLights: core.Point{X: 20, Y: 18}})
Offset moves them from there, as a transition does each frame. TitleBar follows where they are. The zero WindowControls restores the platform's.
func SetWindowFrame ¶
func SetWindowFrame(cx *core.Scope, f WindowFrame)
SetWindowFrame moves and sizes the window: f's top left corner is in points from the main screen's top left on every platform, and fields it leaves out keep their values, so a window given only a new height keeps its top edge. macOS animates the change when f asks. Linux sets the size GTK keeps for the window, and leaves its position to the window manager or compositor; CanPlaceWindows says whether the position moves the window.
func SetWindowLevel ¶
func SetWindowLevel(cx *core.Scope, level WindowLevel)
SetWindowLevel puts the window at level among the others. macOS floats it at NSFloatingWindowLevel, or sinks it to the desktop's icons on every space; Windows makes it topmost, or puts it at the bottom of the z-order; Linux on X11 asks the window manager for _NET_WM_STATE_ABOVE or _NET_WM_STATE_BELOW, again each time the window shows. A Wayland compositor stacks its windows itself, and where CanSetWindowLevel is false the level does nothing.
func SetWindowMaterial ¶
func SetWindowMaterial(cx *core.Scope, m WindowMaterial)
SetWindowMaterial puts m behind the window's content, or makes the window opaque again with WindowMaterialNone; nsgo.WindowMaterial starts the window with one. macOS changes it any time; Windows 11 22H2 and later only in a window started with a material, others staying opaque.
func SetWindowPointerEvents ¶ added in v0.2.0
func SetWindowPointerEvents(cx *core.Scope, p WindowPointerEvents)
SetWindowPointerEvents says where the window takes the pointer, from its next frame: everywhere, the default, nowhere, or only where it draws something, the pointer going through to the windows below elsewhere. WindowOptions.PointerEvents and PanelOptions.PointerEvents open a window so. A window that takes none hears no presses, so an app that lets one through entirely switches it back from elsewhere, such as a global shortcut or a tray icon; one that takes the pointer where it draws hears it there:
desktop.SetWindowPointerEvents(cx, desktop.WindowPointerPainted)
Code held to an Access needs it to grant core.AccessOverlay, else the window takes the pointer. A view whose background fills the window makes a painted window take it everywhere, and the title bar the system draws, which is no view, lets it through.
func SetWindowShadow ¶ added in v0.2.0
SetWindowShadow gives the window the system's shadow, or takes it away; WindowOptions.NoShadow and nsgo.WindowNoShadow open a window without it. Windows draws none around a transparent window and keeps it around a framed one.
func SetWindowTransparent ¶ added in v0.2.0
SetWindowTransparent makes the window transparent, without a background or frame, so what is behind it shows wherever the app draws nothing, or gives it back both; WindowOptions.Transparent and nsgo.WindowTransparent open a window so. It takes effect where CanMakeWindowsTransparent is true: macOS and Linux change it any time, and Windows only in a window opened transparent, whose composition holds from its creation; such a window is opaque, white behind the app's views, while framed.
func SetWindowWorkspaces ¶ added in v0.2.0
func SetWindowWorkspaces(cx *core.Scope, w WindowWorkspaces)
SetWindowWorkspaces shows the window on every workspace, as a desktop pet, a HUD or a timer does, or back on one, the one the user is on; WindowOptions.Workspaces opens a window so. On macOS a window on every Space also shows over other apps' full screen spaces and stays out of Cmd-` cycling, and SetWindowLevel keeps it on every Space; a level that floats keeps it above the windows there, and the desktop's level behind them, out of full screen spaces. Linux puts it on every virtual desktop on X11, where the window manager supports _NET_WM_DESKTOP. Windows, which has no public way to pin a window to every virtual desktop, and Wayland leave it on the one it opened on; CanSetWindowWorkspaces says whether it takes effect.
func ShowsMaterial ¶
ShowsMaterial reports whether a material shows behind the window's content, where the app leaves it transparent. Where it is false, give those parts a background of their own.
func TitleBar ¶
TitleBar returns what a hidden title bar covers: Top is its height, Left and Right the widths the system's window controls take at its ends. It is zero while the system draws the title bar, in full screen and off desktops.
func ToggleFullScreen ¶
ToggleFullScreen enters or leaves full screen.
func ToggleMaximize ¶
ToggleMaximize maximizes (zooms) the window, or restores it.
func Transparent ¶ added in v0.2.0
Transparent reports whether the scope's window or panel draws nothing of its own now, no background, frame or shadow, so what is behind it shows wherever the content draws nothing: a panel opened with PanelOptions.Transparent, or a window opened with WindowOptions.Transparent or nsgo.WindowTransparent or made so by SetWindowTransparent, where the platform could. CanMakeWindowsTransparent says whether a window could be transparent, Transparent whether it is: it turns false as SetWindowTransparent gives the window its frame back, and stays false where the platform could not clear it, as on Linux without a compositor or on Windows in a window not opened transparent. Where it is false, give the content a background of its own.
Types ¶
type FrontmostAppInfo ¶ added in v0.2.0
type FrontmostAppInfo = core.FrontmostAppInfo
FrontmostAppInfo is the application in front on the desktop: its ID, its name, its process ID and whether its frontmost window is in full screen.
func FrontmostApp ¶ added in v0.2.0
func FrontmostApp(cx *core.Scope) FrontmostAppInfo
FrontmostApp returns the application in front on the desktop, the app itself included, tracked: an effect or binding reading it runs again when another app comes to the front or the one in front enters or leaves full screen.
front := desktop.FrontmostApp(cx) coding := front.ID == "com.microsoft.VSCode" && !front.FullScreen
It is zero where CanReadFrontmostApp is false. Tests set it with nsgotest.Environment(core.Environment{FrontmostApp: ..., CanReadFrontmostApp: true}).
type GuideOptions ¶
type GuideOptions = core.PermissionGuideOptions
GuideOptions say which app GuidePermission holds out for the user to drag.
type HotKey ¶
HotKey is a global shortcut's registration, whose State follows the platform's answers.
func RegisterHotKey ¶
RegisterHotKey runs fn when key, in core.Scope.OnKey's form such as "alt+space", is pressed whichever app has the focus, while the current owner lives. The handle's State is Pending until the platform answers, then Registered, Taken or Unsupported, and Pending again while a change to the app's shortcuts registers them anew. Global shortcuts work on macOS, on Linux and, for an app run with nsgo.Run(App), on Windows; elsewhere, nsgo.NewView's hosts included, the handle is Unsupported. Linux uses X11 passive grabs, and its compositor's global-shortcut portal on Wayland, where the shortcut is Registered once the user accepts the binding, and Taken when the binding leaves it out.
type HotKeyState ¶
type HotKeyState = core.HotKeyState
HotKeyState is what the platform answered a global shortcut's registration.
type MenuBarMode ¶
type MenuBarMode = core.MenuBarMode
MenuBarMode says when Windows and Linux show the menu bar.
type MenuItem ¶
MenuItem is one item of a menu: an action, a submenu when it has Items, or a line between groups when Separator. The application menu's top-level items are the menu bar's menus; on macOS the first is the app menu.
type MenuRole ¶
MenuRole is a standard menu item the platform carries out, labelling it and giving it its usual shortcut when the item has none of its own.
type PanelOptions ¶
type PanelOptions = core.PanelOptions
PanelOptions are a panel's size, whether it takes its content's, whether it hides as it loses the focus, whether it never takes it, whether it draws anything of its own, and where it takes the pointer.
type QuitRequest ¶
type QuitRequest = core.QuitRequest
QuitRequest is a quit the user asked for, which OnQuitRequest's handlers may cancel, or defer while they ask the user.
type ShutdownMode ¶
type ShutdownMode = core.ShutdownMode
ShutdownMode says when the app ends by itself.
type TitleBarStyle ¶
type TitleBarStyle = core.TitleBarStyle
TitleBarStyle is whether the system draws the window's title bar.
type TrayOptions ¶
type TrayOptions = core.TrayOptions
TrayOptions are a tray icon's image or view, and what its clicks show.
type Window ¶
Window is a window or a panel the app opened.
func CurrentWindow ¶
CurrentWindow returns the window cx is in, nil in the app's own scope.
func MainWindow ¶
MainWindow returns the main window, nil once it closed.
func OpenPanel ¶
OpenPanel opens a hidden panel showing content: a borderless window above the others, which takes the keyboard without activating the app, for Window.Toggle, a global shortcut or a tray icon to show, as a launcher or a tray icon's panel does. With PanelOptions.NoActivate it never takes the keyboard, for Window.ShowAt to place beside another app's text caret, as an input method's candidate window does:
candidates := desktop.OpenPanel(cx, desktop.PanelOptions{Width: 320, Height: 40, NoActivate: true}, Candidates)
candidates.ShowAt(caret, core.PlaceBottom)
A popup card draws itself on a Transparent panel, which shows nothing around it, sized to it with FitContent, up to Width and Height:
lookup := desktop.OpenPanel(cx, desktop.PanelOptions{Width: 380, Height: 520, FitContent: true, Transparent: true, HideOnBlur: true}, Card)
func OpenWindow ¶
OpenWindow opens a window showing content, which belongs to the current owner and closes when that owner goes. A window with opts.Key already open shows and takes the focus instead:
settings := desktop.OpenWindow(cx, desktop.WindowOptions{Title: "Settings", Key: "settings"}, Settings)
type WindowClosing ¶
type WindowClosing = core.WindowClosing
WindowClosing is a close the user asked for, which Window.OnClosing may cancel.
type WindowConstraints ¶
type WindowConstraints = core.WindowConstraints
WindowConstraints limit a window's size and what the user may do to it.
type WindowControls ¶
type WindowControls = core.WindowControls
WindowControls is how a hidden title bar shows the system's window controls: hidden for the app to draw its own, or macOS's traffic lights moved.
type WindowFrame ¶
type WindowFrame = core.WindowFrame
WindowFrame is where a window moves and how large it becomes, in points from the main screen's top left.
func Frame ¶
func Frame(cx *core.Scope) WindowFrame
Frame returns where the window is and how large, as SetWindowFrame and nsgo.WindowFrame take them, changing as it moves and resizes. While the window is maximized or in full screen it is that frame, so an app remembering a window keeps the one it last had otherwise. Linux knows only the size GTK keeps, which ignores those states, and Move says no position came; zero without a window.
type WindowLevel ¶
type WindowLevel = core.WindowLevel
WindowLevel is where a window stacks among the others.
type WindowMaterial ¶
type WindowMaterial = core.WindowMaterial
WindowMaterial is a translucent material behind the window's content: one of macOS's vibrancy materials, or of Windows 11's system backdrops, each platform showing its closest.
type WindowOptions ¶
type WindowOptions = core.WindowOptions
WindowOptions are a window's title, size, constraints, key and where it takes the pointer.
type WindowPointerEvents ¶ added in v0.2.0
type WindowPointerEvents = core.WindowPointerEvents
WindowPointerEvents is where a window takes the pointer: everywhere, nowhere, or only where it draws something.
type WindowWorkspaces ¶ added in v0.2.0
type WindowWorkspaces = core.WindowWorkspaces
WindowWorkspaces are the workspaces a window shows on: macOS's Spaces, the virtual desktops of Windows and Linux.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package locales says the words the backends show and announce in the language the app shows: those of the platforms' menus, the standard items' and the menus apps build around them, of macOS's permission guide, its panel with the titles of System Settings' privacy panes, and the roles and states the screen readers of Android and Windows announce where the system has no word of its own.
|
Package locales says the words the backends show and announce in the language the app shows: those of the platforms' menus, the standard items' and the menus apps build around them, of macOS's permission guide, its panel with the titles of System Settings' privacy panes, and the roles and states the screen readers of Android and Windows announce where the system has no word of its own. |