Documentation
¶
Index ¶
- Variables
- func AddGlobalShortcut(keys KeyCombination, handler func())
- func BundleInfo(key string) string
- func Loop(args []string, onReady func(*App)) error
- func RedirectStderr(path string) (*os.File, error)
- func RedirectStdout(path string) (*os.File, error)
- func RedirectStdoutStderr(path string) (*os.File, error)
- func RunApplication()
- type App
- type Image
- type KeyCombination
- type Menu
- type MenuEntry
- type MenuItem
- type Modifier
- type Notification
- type Rect
- type Screen
- type StatusItemOptions
- type Window
- func (w *Window) Close()
- func (w *Window) CloseDevTools()
- func (w *Window) Copy()
- func (w *Window) Cut()
- func (w *Window) Delete()
- func (w *Window) DevToolsAreOpen() bool
- func (w *Window) LoadURL(url string)
- func (w *Window) Miniaturize()
- func (w *Window) NativeController() unsafe.Pointer
- func (w *Window) NativeWindow() unsafe.Pointer
- func (w *Window) Open()
- func (w *Window) OpenDevTools()
- func (w *Window) Paste()
- func (w *Window) PasteAndMatchStyle()
- func (w *Window) Redo()
- func (w *Window) Reload()
- func (w *Window) ReloadNoCache()
- func (w *Window) SelectAll()
- func (w *Window) SetShape(r Rect)
- func (w *Window) Shape() Rect
- func (w *Window) URL() string
- func (w *Window) Undo()
- func (w *Window) Unselect()
- type WindowOptions
Constants ¶
This section is empty.
Variables ¶
var (
ErrImageDecodeFailed = errors.New("image could not be decoded")
)
var FramedWindow = WindowOptions{ Shape: Rect{ Width: 800, Height: 600, Left: 100, Bottom: 100, }, TitleBar: true, Frame: true, Resizable: true, CloseButton: true, MinButton: true, FullScreenButton: true, Title: defaultWindowTitle(), }
FramedWindow contains options for an "ordinary" window with title bar, frame, and min/max/close buttons.
var FramelessWindow = WindowOptions{ Shape: Rect{ Width: 800, Height: 600, Left: 100, Bottom: 100, }, Resizable: true, }
FramelessWindow contains options for a window with no frame or border, but that is still resizable.
Functions ¶
func AddGlobalShortcut ¶
func AddGlobalShortcut(keys KeyCombination, handler func())
AddGlobalShortcut calls the handler whenever the key combination is pressed in any application.
func BundleInfo ¶
BundleInfo looks up an entry in the Info.plist for the current bundle.
func Loop ¶
Loop starts the browser loop and does not return unless there is an initialization error
func RedirectStderr ¶
RedirectStderr overwrites the stderr streams with a file descriptor that writes to the given path. This is done with os.Dup2, meaning that even C functions that write to stderr will be redirected to the file.
func RedirectStdout ¶
RedirectStdout overwrites the stdout streams with a file descriptor that writes to the given path. This is done with os.Dup2, meaning that even C functions that write to stdout will be redirected to the file.
func RedirectStdoutStderr ¶
RedirectStdoutStderr overwrites the stdout and stderr streams with a file descriptor that writes to the given path. This is done with os.Dup2, meaning that even C functions that write to stdout or stderr will be redirected to the file.
func RunApplication ¶
func RunApplication()
RunApplication is for debugging only. It allows creation of menus and desktop notifications without firing up any parts of chromium. It will be removed before the 1.0 release.
Types ¶
type App ¶
type App struct {
// contains filtered or unexported fields
}
App is the handle that allows you to create windows and menus
func (*App) AddStatusItem ¶
func (app *App) AddStatusItem(opts StatusItemOptions)
func (*App) OpenWindow ¶
func (app *App) OpenWindow(url string, opt WindowOptions) (*Window, error)
OpenWindow creates a window that will load the given URL.
type Image ¶
type Image struct {
// contains filtered or unexported fields
}
Image holds a handle to a platform-specific image structure (e.g. NSImage on macOS).
func ImageFromPNG ¶
ImageFromPNG creates an image from a buffer containing a PNG-encoded image.
type KeyCombination ¶
KeyCombination represents a key together with zero or more modifiers. It is used to set up keyboard shortcuts.
func MustParseKeys ¶
func MustParseKeys(s string) KeyCombination
MustParseKeys is like ParseKeys but panics on error
func ParseKeys ¶
func ParseKeys(s string) (KeyCombination, error)
ParseKeys parses a key combination specified as a string like "cmd shift a".
type MenuEntry ¶
type MenuEntry interface {
// contains filtered or unexported methods
}
MenuEntry is the interface for menus and menu items.
var Separator MenuEntry
Separator displays a horizontal separator within a menu
type MenuItem ¶
type MenuItem struct { Title string Shortcut KeyCombination OnClick func() }
A MenuItem has a title and can be clicked on. It is a leaf node in the menu tree.
type Modifier ¶
type Modifier int
Modifier represents zero or more modifier keys (control, shift, option, etc)
type Notification ¶
type Notification struct { Title string Subtitle string InformativeText string Image *Image Identifier string ActionButtonTitle string OtherButtonTitle string }
Notification represents a desktop notification
type Rect ¶
type Rect struct { Width int // Width in pixels Height int // Height in pixels Left int // Left is offset from left in pixel Bottom int // Left is offset from top in pixels }
Rect represents a rectangular region on the screen
type Screen ¶
type Screen struct { Shape Rect // the size and position of this screen in global coords Usable Rect // excludes the menubar and dock BitsPerPixel int // color depth of this screen (total of all color components) ID int // unique identifier for this screen }
A screen represents a rectangular display, normally corresponding to a physical display. "Device coordinates" means a position on a screen measured from (0, 0) at the bottom left of the device. "Global coordinates" means the coordinate system in which each of the screens are positioned relative to each other. Global and device coordinates almost always have the same scale factor. It is possible for screens to overlap in global coordinates (such as when mirroring a display.)
func FocusedScreen ¶
func FocusedScreen() Screen
FocusedScreen gets the screen containing the currently focused window
type StatusItemOptions ¶
type Window ¶
type Window struct {
// contains filtered or unexported fields
}
Window represents a window registered with the native UI toolkit (e.g. NSWindow on macOS)
func (*Window) Close ¶
func (w *Window) Close()
Close closes the window, as if the close button had been clicked.
func (*Window) CloseDevTools ¶
func (w *Window) CloseDevTools()
CloseDevTools closes the developer tools.
func (*Window) Copy ¶
func (w *Window) Copy()
Copy copies the current text selection to the pasteboard
func (*Window) DevToolsAreOpen ¶
DevToolsVisible returns whether the developer tools are showing
func (*Window) Miniaturize ¶
func (w *Window) Miniaturize()
Miniaturize miniaturizes the window, as if the min button had been clicked.
func (*Window) NativeController ¶
NativeWindow gets an operating-system dependent handle for the window controller. Under macOS this is *NSWindowController.
func (*Window) NativeWindow ¶
NativeWindow gets a operating-system dependent handle for this window. Under macOS this is NSWindow*.
func (*Window) Open ¶
func (w *Window) Open()
Open opens the window. This is the default state for a window created via OpenWindow, so you only need to call this if you manually closed the window.
func (*Window) OpenDevTools ¶
func (w *Window) OpenDevTools()
OpenDevTools opens the developer tools for this window.
func (*Window) PasteAndMatchStyle ¶
func (w *Window) PasteAndMatchStyle()
PasteAndMatchStyle pastes from the pasteboard, matching style to the current element
func (*Window) ReloadNoCache ¶
func (w *Window) ReloadNoCache()
Reload reloads the current URL, ignoring cached versions of resources.
func (*Window) SelectAll ¶
func (w *Window) SelectAll()
SelectAll selects all text in the current element
type WindowOptions ¶
type WindowOptions struct { Title string // String to display in title bar Shape Rect // Initial size and position of window TitleBar bool // Whether the window title bar Frame bool // Whether the window has a frame Resizable bool // Whether the window border can be dragged to change its shape CloseButton bool // Whether the window has a close button MinButton bool // Whether the window has a miniaturize button FullScreenButton bool // Whether the window has a full screen button Menu []MenuEntry }
WindowOptions contains options for creating windows