Documentation
¶
Index ¶
- func Main()
- func Screenshot(content core.Widget, width, height int, path string) error
- func ScreenshotAtScale(content core.Widget, width, height int, scale float32, path string) error
- func SetIcon(artwork []byte) error
- func SocketDir() string
- type Element
- type Options
- type Snapshot
- type Window
- func (w *Window) Activate(token string)
- func (w *Window) Close()
- func (w *Window) Closed() bool
- func (w *Window) Focused() bool
- func (w *Window) Frameless() bool
- func (w *Window) Maximized() bool
- func (w *Window) Minimize()
- func (w *Window) Raise()
- func (w *Window) TitleBarArea(x, y, width, height float32)
- func (w *Window) ToggleMaximize()
- func (w *Window) WaylandDisplay() unsafe.Pointer
- type WindowInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Main ¶
func Main()
Main runs the platform event loop. The process exits after the last window closes. With KEEL_AUTOMATION set it also serves automation requests, or only those with KEEL_HEADLESS=1; see automation.go.
func Screenshot ¶
Screenshot renders content as a window would, off-screen at 2× scale, and writes a PNG. Width and height are in dp.
func ScreenshotAtScale ¶
ScreenshotAtScale renders the first frame at an explicit pixel density. Dimensions are in dp; scale must be finite and positive.
func SetIcon ¶ added in v0.0.7
SetIcon sets the app's icon from full-bleed square PNG artwork, as in a keel project's appicon.png: macOS shows it in the Dock with Apple's plate and shadow; Windows on every window's title bar and taskbar button; Linux X11 on every window (_NET_WM_ICON). Wayland and the browser take their icon from the installed .desktop entry and the page, so SetIcon does nothing there. It applies to open windows and to those opened later; call it before Open, or any time to change the icon.
Types ¶
type Element ¶
type Element struct {
Ref string `json:"ref"`
Role string `json:"role"` // see roleOf
Name string `json:"name,omitempty"`
Value string `json:"value,omitempty"` // textbox content, select choice, progress
Checked *bool `json:"checked,omitempty"` // checkbox, radio, switch
Selected *bool `json:"selected,omitempty"` // tab, row, option; a button only when selected
Disabled bool `json:"disabled,omitempty"`
X int `json:"x"`
Y int `json:"y"`
Width int `json:"width"`
Height int `json:"height"`
}
Element is one node of a window's semantic tree, as reported to agents.
type Options ¶
type Options struct {
Title string
Width, Height int
Content core.Widget
// Overlay is drawn over the whole window, above Content, for hand-written
// Gio content; el views declare overlays with cx.Overlay instead. It should
// take no space while it has nothing to show.
Overlay core.Widget
// Shortcuts maps accelerators to callbacks while the window has focus, e.g.
// "mod+," (Cmd on macOS, Ctrl elsewhere), "ctrl+shift+s", "esc".
Shortcuts map[string]func()
OnClose func()
// Frameless hides the system title bar so the content can draw its own,
// e.g. a kit.TitleBar; the content then starts at the window's top edge.
Frameless bool
}
Options configures a window. Width and Height are in dp; zero uses 640×480.
type Snapshot ¶
type Snapshot struct {
Window WindowInfo `json:"window"`
Elements []Element `json:"elements"`
}
Snapshot is a window and its elements.
type Window ¶
type Window struct {
// contains filtered or unexported fields
}
func Open ¶
Open creates and shows a centered window where the platform supports it. Call it before Main or from any callback. It panics on an invalid shortcut, which is a programming error.
func (*Window) Activate ¶ added in v0.0.4
Activate brings the window to the front with an activation token that another program granted, such as notification.Activation.Token after a system notification was clicked. Window managers let a token through their focus-stealing prevention, where a plain Raise may only flash the taskbar. On Wayland the token goes to xdg-activation; on X11 it is a startup ID. Elsewhere, with an empty token, or if the platform refuses, Activate is Raise.
func (*Window) Close ¶
func (w *Window) Close()
Close closes the window as if the user clicked its close button.
func (*Window) Minimize ¶
func (w *Window) Minimize()
Minimize hides the window in the Dock or taskbar.
func (*Window) TitleBarArea ¶
func (*Window) ToggleMaximize ¶
func (w *Window) ToggleMaximize()
ToggleMaximize maximizes the window (zooms it on macOS), or restores it when it is maximized.
func (*Window) WaylandDisplay ¶ added in v0.0.4
WaylandDisplay is this window's wl_display on Linux Wayland, nil elsewhere or before the window is shown. Pass it to native/clipboard's UseWaylandDisplay to read the clipboard while this window has focus.