Documentation
¶
Index ¶
- Constants
- Variables
- func AllWindowsToFront()
- func AttemptQuit()
- func Count() int
- func Initialize(platformDriver Driver) (*cef.MainArgs, error)
- func InvokeUITask(task func())
- func InvokeUITaskAfter(task func(), after time.Duration)
- func MayQuitNow(quit bool)
- func MenuBarHeight() float64
- func Start(args *cef.MainArgs, settings *cef.Settings, application *cef.App) error
- type AppVisibilityController
- type Display
- type Driver
- type Menu
- func (menu *Menu) Count() int
- func (menu *Menu) Dispose()
- func (menu *Menu) InsertItem(beforeIndex, id int, title string, key *keys.Key, keyModifiers keys.Modifiers, ...)
- func (menu *Menu) InsertMenu(beforeIndex, id int, title string) *Menu
- func (menu *Menu) InsertSeparator(beforeIndex int)
- func (menu *Menu) Item(id int) *MenuItem
- func (menu *Menu) ItemAtIndex(index int) *MenuItem
- func (menu *Menu) Remove(index int)
- func (menu *Menu) SetItemAtIndexTitle(index int, title string)
- func (menu *Menu) SetItemTitle(id int, title string)
- type MenuBar
- func (bar *MenuBar) Count() int
- func (bar *MenuBar) IndexOf(menu *Menu) int
- func (bar *MenuBar) InsertMenu(beforeIndex int, menu *Menu)
- func (bar *MenuBar) Menu(id int) *Menu
- func (bar *MenuBar) MenuAtIndex(index int) *Menu
- func (bar *MenuBar) MenuItem(id int) *MenuItem
- func (bar *MenuBar) Remove(index int)
- type MenuItem
- type QuitResponse
- type StyleMask
- type Window
- func (window *Window) AttemptClose()
- func (window *Window) Bounds() geom.Rect
- func (window *Window) Closable() bool
- func (window *Window) Dispose()
- func (window *Window) Focused() bool
- func (window *Window) Minimizable() bool
- func (window *Window) Minimize()
- func (window *Window) Resizable() bool
- func (window *Window) SetBounds(bounds geom.Rect)
- func (window *Window) SetTitle(title string)
- func (window *Window) String() string
- func (window *Window) ThemeIsDark() bool
- func (window *Window) Title() string
- func (window *Window) ToFront()
- func (window *Window) ToggleDevTools()
- func (window *Window) WindowContentSize() geom.Size
- func (window *Window) Zoom()
Constants ¶
const ( MenuIDAppMenu = int(cef.MenuIDUserFirst) + iota MenuIDFileMenu MenuIDEditMenu MenuIDWindowMenu MenuIDHelpMenu MenuIDServicesMenu MenuIDAboutItem MenuIDDevToolsItem MenuIDPreferencesItem MenuIDQuitItem MenuIDCutItem MenuIDCopyItem MenuIDPasteItem MenuIDDeleteItem MenuIDSelectAllItem MenuIDMinimizeItem MenuIDZoomItem MenuIDBringAllWindowsToFrontItem MenuIDCloseItem MenuIDHideItem MenuIDHideOthersItem MenuIDShowAllItem MenuIDUserBase = MenuIDAppMenu + 250 )
Pre-defined menu IDs. Apps should start their IDs at MenuIDUserBase.
Variables ¶
var CheckQuitCallback = func() QuitResponse { return Now }
CheckQuitCallback is called when termination has been requested. Default returns Now.
var DidActivateCallback = func() {}
DidActivateCallback is called once the application is activated.
var DidDeactivateCallback = func() {}
DidDeactivateCallback is called once the application is deactivated.
var DidFinishStartupCallback = func() {}
DidFinishStartupCallback is called once application startup has completed.
var QuitAfterLastWindowClosedCallback = func() bool { return true }
QuitAfterLastWindowClosedCallback is called when the last window is closed to determine if the application should quit as a result. Default returns yes.
var QuittingCallback = func() {}
QuittingCallback is called when the app will in fact terminate.
var ThemeChangedCallback = func() {}
ThemeChangedCallback is called when the theme is changed.
var WillActivateCallback = func() {}
WillActivateCallback is called right before the application is activated.
var WillDeactivateCallback = func() {}
WillDeactivateCallback is called right before the application is deactivated.
var WillFinishStartupCallback = func() {}
WillFinishStartupCallback is called right before application startup has completed. This is a good point to create any windows your app wants to display.
Functions ¶
func AllWindowsToFront ¶
func AllWindowsToFront()
AllWindowsToFront attempts to bring all of the application's windows to the foreground.
func Initialize ¶
Initialize the library. This should be called on the main OS thread as early as possible -- typically before parsing command-line arguments, as this may be a request to start a sub-process and not the primary application.
Note that starting goroutines may cause your code to start executing on a secondary thread, so either make this call prior to starting goroutines, or explicitly call runtime.LockOSThread() before doing so.
This function will not return if the executable is being started as a CEF sub-process.
func InvokeUITask ¶
func InvokeUITask(task func())
InvokeUITask a task on the UI thread. The task is put into the system event queue and will be run at the next opportunity.
func InvokeUITaskAfter ¶
InvokeUITaskAfter schedules a task to be run on the UI thread after waiting for the specified duration.
func MayQuitNow ¶
func MayQuitNow(quit bool)
MayQuitNow resumes the termination sequence that was delayed when Later is returned from CheckQuit. Passing in false for the quit parameter will cancel the termination sequence while true will allow it to proceed.
func MenuBarHeight ¶
func MenuBarHeight() float64
MenuBarHeight returns the height of the MenuBar when displayed in a window.
Types ¶
type AppVisibilityController ¶
type AppVisibilityController interface {
HideApp()
HideOtherApps()
ShowAllApps()
}
AppVisibilityController defines optional APIs a platform can provide for manipulating application visibility.
type Driver ¶
type Driver interface {
PrepareForStart() error
PrepareForEventLoop()
RunEventLoop()
OnPreKeyEvent(event *cef.KeyEvent, isKeyboardShortcut *int32) int32
OnKeyEvent(event *cef.KeyEvent) int32
AttemptQuit()
MayQuitNow(quit bool)
MenuBarForWindow(wnd *Window) (bar *MenuBar, isGlobal, isFirst bool)
MenuBarMenuAtIndex(bar *MenuBar, index int) *Menu
MenuBarInsert(bar *MenuBar, beforeIndex int, menu *Menu)
MenuBarRemove(bar *MenuBar, index int)
MenuBarCount(bar *MenuBar) int
MenuBarHeightInWindow() float64
MenuInit(menu *Menu)
MenuItemAtIndex(menu *Menu, index int) *MenuItem
MenuItemAtIndexSetTitle(menu *Menu, index int, title string)
MenuInsertSeparator(menu *Menu, beforeIndex int)
MenuInsertItem(menu *Menu, beforeIndex, id int, title string, key *keys.Key, keyModifiers keys.Modifiers, validator func() bool, handler func())
MenuInsertMenu(menu *Menu, beforeIndex, id int, title string) *Menu
MenuRemove(menu *Menu, index int)
MenuCount(menu *Menu) int
MenuDispose(menu *Menu)
Displays() []*Display
KeyWindow() *Window
BringAllWindowsToFront()
WindowInit(wnd *Window, style StyleMask, bounds geom.Rect, title string) error
WindowBrowserParent(wnd *Window) unsafe.Pointer
WindowClose(wnd *Window)
WindowSetTitle(wnd *Window, title string)
WindowBounds(wnd *Window) geom.Rect
WindowSetBounds(wnd *Window, bounds geom.Rect)
WindowContentSize(wnd *Window) geom.Size
WindowToFront(wnd *Window)
WindowMinimize(wnd *Window)
WindowZoom(wnd *Window)
WindowThemeIsDark(wnd *Window) bool
}
Driver defines the required functions each platform driver must provide.
type Menu ¶
Menu represents a set of menu items.
func (*Menu) Dispose ¶
func (menu *Menu) Dispose()
Dispose releases any operating system resources associated with this menu.
func (*Menu) InsertItem ¶
func (menu *Menu) InsertItem(beforeIndex, id int, title string, key *keys.Key, keyModifiers keys.Modifiers, validator func() bool, handler func())
InsertItem inserts a menu item at the specified item index within this menu. Pass in a negative index to append to the end. Both 'validator' and 'handler' may be nil for default behavior.
func (*Menu) InsertMenu ¶
InsertMenu inserts a new sub-menu at the specified item index within this menu. Pass in a negative index to append to the end.
func (*Menu) InsertSeparator ¶
InsertSeparator inserts a menu separator at the specified item index within this menu. Pass in a negative index to append to the end.
func (*Menu) Item ¶
Item returns the menu item with the specified id anywhere in the menu and and its sub-menus.
func (*Menu) ItemAtIndex ¶
ItemAtIndex returns the menu item at the specified index within the menu.
func (*Menu) SetItemAtIndexTitle ¶
SetItemAtIndexTitle sets the title of the menu item at the specified index within the menu.
func (*Menu) SetItemTitle ¶
SetItemTitle sets the title of the menu item with the specified id anywhere in the menu and its sub-menus.
type MenuBar ¶
type MenuBar struct {
PlatformData interface{}
}
MenuBar represents a set of menus.
func MenuBarForWindow ¶
MenuBarForWindow returns the menu bar for the given window. On macOS, the menu bar is a global entity and the same value will be returned for all windows. On macOS, you may pass nil for the window parameter. If isGlobal is true, the first time this function is called, isFirst will be true as well, allowing you to only initialize the global menu bar once.
func (*MenuBar) InsertMenu ¶
InsertMenu inserts a menu at the specified item index within this menu bar. Pass in a negative index to append to the end.
func (*MenuBar) Menu ¶
Menu returns the menu with the specified id anywhere in the menu bar and its sub-menus.
func (*MenuBar) MenuAtIndex ¶
MenuAtIndex returns the menu at the specified index within the menu bar.
type QuitResponse ¶
type QuitResponse int
QuitResponse is used to respond to requests for app termination.
const ( Cancel QuitResponse = iota Now Later // Must make a call to MayQuitNow() at some point in the future. )
Possible termination responses
type StyleMask ¶
type StyleMask int
StyleMask controls the look and capabilities of a window.
const ( TitledWindowMask StyleMask = 1 << iota ClosableWindowMask MinimizableWindowMask ResizableWindowMask BorderlessWindowMask = 0 StdWindowMask = TitledWindowMask | ClosableWindowMask | MinimizableWindowMask | ResizableWindowMask )
Possible values for the StyleMask.
type Window ¶
type Window struct {
PlatformData interface{}
Browser *cef.Browser
// MayCloseCallback is called when the user has requested that the window
// be closed. Return true to permit it, false to cancel the operation.
// Defaults to always returning true.
MayCloseCallback func() bool
// WillCloseCallback is called just prior to the window closing.
WillCloseCallback func()
// GainedFocus is called when the keyboard focus is gained on this window.
GainedFocus func()
// LostFocus is called when the keyboard focus is lost from this window.
LostFocus func()
// contains filtered or unexported fields
}
Window holds window information.
func KeyWindow ¶
func KeyWindow() *Window
KeyWindow returns the window that currently has the keyboard focus, or nil if none of your application's windows has the keyboard focus.
func Windows ¶
func Windows() []*Window
Windows returns a slice containing the current set of open windows.
func (*Window) AttemptClose ¶
func (window *Window) AttemptClose()
AttemptClose closes the window if permitted.
func (*Window) Bounds ¶
Bounds returns the boundaries in display coordinates of the frame of this window (i.e. the area that includes both the content and its border and window controls).
func (*Window) Closable ¶
Closable returns true if the window was created with the ClosableWindowMask.
func (*Window) Minimizable ¶
Minimizable returns true if the window was created with the MinimizableWindowMask.
func (*Window) Minimize ¶
func (window *Window) Minimize()
Minimize performs the platform's minimize function on the window.
func (*Window) Resizable ¶
Resizable returns true if the window was created with the ResizableWindowMask.
func (*Window) ThemeIsDark ¶ added in v0.2.1
ThemeIsDark returns true if the window theme is a dark one.
func (*Window) ToFront ¶
func (window *Window) ToFront()
ToFront attempts to bring the window to the foreground and give it the keyboard focus.
func (*Window) ToggleDevTools ¶
func (window *Window) ToggleDevTools()
ToggleDevTools toggles display of the Chrome development tools window.
func (*Window) WindowContentSize ¶
WindowContentSize returns the size of the windoe's content area.