5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-04 21:19:04 +08:00
wails/mkdocs-website/docs/en/API/fullapi.md
Fabio Massaioli 7e687750b2
[v3] Add option for showing the toolbar in fullscreen mode on macOS (#3282)
* Add option for showing the toolbar in fullscreen mode on macOS

* Add an example demonstrating the ShowToolbarWhenFullscreen option

* Update docs

* Add changelog entry

* Run go mod tidy
2024-03-02 20:10:25 +11:00

131 KiB

application

import "github.com/wailsapp/wails/v3/pkg/application"

Index

Constants

const (
    ApplicationHide = 0
    ApplicationShow = 1
    ApplicationQuit = 2
)

const (
    ClipboardSetText = 0
    ClipboardText    = 1
)

const (
    DialogInfo     = 0
    DialogWarning  = 1
    DialogError    = 2
    DialogQuestion = 3
    DialogOpenFile = 4
    DialogSaveFile = 5
)

const (
    ScreensGetAll     = 0
    ScreensGetPrimary = 1
    ScreensGetCurrent = 2
)

const (
    WindowCenter              = 0
    WindowSetTitle            = 1
    WindowFullscreen          = 2
    WindowUnFullscreen        = 3
    WindowSetSize             = 4
    WindowSize                = 5
    WindowSetMaxSize          = 6
    WindowSetMinSize          = 7
    WindowSetAlwaysOnTop      = 8
    WindowSetRelativePosition = 9
    WindowRelativePosition    = 10
    WindowScreen              = 11
    WindowHide                = 12
    WindowMaximise            = 13
    WindowUnMaximise          = 14
    WindowToggleMaximise      = 15
    WindowMinimise            = 16
    WindowUnMinimise          = 17
    WindowRestore             = 18
    WindowShow                = 19
    WindowClose               = 20
    WindowSetBackgroundColour = 21
    WindowSetResizable        = 22
    WindowWidth               = 23
    WindowHeight              = 24
    WindowZoomIn              = 25
    WindowZoomOut             = 26
    WindowZoomReset           = 27
    WindowGetZoomLevel        = 28
    WindowSetZoomLevel        = 29
)

const (
    NSImageNone = iota
    NSImageOnly
    NSImageLeft
    NSImageRight
    NSImageBelow
    NSImageAbove
    NSImageOverlaps
    NSImageLeading
    NSImageTrailing
)

const (
    CallBinding = 0
)

const (
    ContextMenuOpen = 0
)

const (
    EventsEmit = 0
)

const (
    MenuItemMsgID = w32.WM_APP + 1024
)

const (
    SystemIsDarkMode = 0
)

const (
    WM_USER_SYSTRAY = w32.WM_USER + 1
)

Variables

BuildInfo contains the build info for the application

var BuildInfo *debug.BuildInfo

BuildSettings contains the build settings for the application

var BuildSettings map[string]string

MacTitleBarDefault results in the default Mac MacTitleBar

var MacTitleBarDefault = MacTitleBar{
    AppearsTransparent:   false,
    Hide:                 false,
    HideTitle:            false,
    FullSizeContent:      false,
    UseToolbar:           false,
    HideToolbarSeparator: false,
}

MacTitleBarHidden results in a hidden title bar and a full size content window, yet the title bar still has the standard window controls “traffic lights” in the top left.

var MacTitleBarHidden = MacTitleBar{
    AppearsTransparent:   true,
    Hide:                 false,
    HideTitle:            true,
    FullSizeContent:      true,
    UseToolbar:           false,
    HideToolbarSeparator: false,
}

MacTitleBarHiddenInset results in a hidden title bar with an alternative look where the traffic light buttons are slightly more inset from the window edge.

var MacTitleBarHiddenInset = MacTitleBar{
    AppearsTransparent:   true,
    Hide:                 false,
    HideTitle:            true,
    FullSizeContent:      true,
    UseToolbar:           true,
    HideToolbarSeparator: true,
}

MacTitleBarHiddenInsetUnified results in a hidden title bar with an alternative look where the traffic light buttons are even more inset from the window edge.

var MacTitleBarHiddenInsetUnified = MacTitleBar{
    AppearsTransparent:   true,
    Hide:                 false,
    HideTitle:            true,
    FullSizeContent:      true,
    UseToolbar:           true,
    HideToolbarSeparator: true,
    ToolbarStyle:         MacToolbarStyleUnified,
}

var VirtualKeyCodes = map[uint]string{
    0x01: "lbutton",
    0x02: "rbutton",
    0x03: "cancel",
    0x04: "mbutton",
    0x05: "xbutton1",
    0x06: "xbutton2",
    0x08: "back",
    0x09: "tab",
    0x0C: "clear",
    0x0D: "return",
    0x10: "shift",
    0x11: "control",
    0x12: "menu",
    0x13: "pause",
    0x14: "capital",
    0x15: "kana",
    0x17: "junja",
    0x18: "final",
    0x19: "hanja",
    0x1B: "escape",
    0x1C: "convert",
    0x1D: "nonconvert",
    0x1E: "accept",
    0x1F: "modechange",
    0x20: "space",
    0x21: "prior",
    0x22: "next",
    0x23: "end",
    0x24: "home",
    0x25: "left",
    0x26: "up",
    0x27: "right",
    0x28: "down",
    0x29: "select",
    0x2A: "print",
    0x2B: "execute",
    0x2C: "snapshot",
    0x2D: "insert",
    0x2E: "delete",
    0x2F: "help",
    0x30: "0",
    0x31: "1",
    0x32: "2",
    0x33: "3",
    0x34: "4",
    0x35: "5",
    0x36: "6",
    0x37: "7",
    0x38: "8",
    0x39: "9",
    0x41: "a",
    0x42: "b",
    0x43: "c",
    0x44: "d",
    0x45: "e",
    0x46: "f",
    0x47: "g",
    0x48: "h",
    0x49: "i",
    0x4A: "j",
    0x4B: "k",
    0x4C: "l",
    0x4D: "m",
    0x4E: "n",
    0x4F: "o",
    0x50: "p",
    0x51: "q",
    0x52: "r",
    0x53: "s",
    0x54: "t",
    0x55: "u",
    0x56: "v",
    0x57: "w",
    0x58: "x",
    0x59: "y",
    0x5A: "z",
    0x5B: "lwin",
    0x5C: "rwin",
    0x5D: "apps",
    0x5F: "sleep",
    0x60: "numpad0",
    0x61: "numpad1",
    0x62: "numpad2",
    0x63: "numpad3",
    0x64: "numpad4",
    0x65: "numpad5",
    0x66: "numpad6",
    0x67: "numpad7",
    0x68: "numpad8",
    0x69: "numpad9",
    0x6A: "multiply",
    0x6B: "add",
    0x6C: "separator",
    0x6D: "subtract",
    0x6E: "decimal",
    0x6F: "divide",
    0x70: "f1",
    0x71: "f2",
    0x72: "f3",
    0x73: "f4",
    0x74: "f5",
    0x75: "f6",
    0x76: "f7",
    0x77: "f8",
    0x78: "f9",
    0x79: "f10",
    0x7A: "f11",
    0x7B: "f12",
    0x7C: "f13",
    0x7D: "f14",
    0x7E: "f15",
    0x7F: "f16",
    0x80: "f17",
    0x81: "f18",
    0x82: "f19",
    0x83: "f20",
    0x84: "f21",
    0x85: "f22",
    0x86: "f23",
    0x87: "f24",
    0x88: "navigation_view",
    0x89: "navigation_menu",
    0x8A: "navigation_up",
    0x8B: "navigation_down",
    0x8C: "navigation_left",
    0x8D: "navigation_right",
    0x8E: "navigation_accept",
    0x8F: "navigation_cancel",
    0x90: "numlock",
    0x91: "scroll",
    0x92: "oem_nec_equal",
    0x93: "oem_fj_masshou",
    0x94: "oem_fj_touroku",
    0x95: "oem_fj_loya",
    0x96: "oem_fj_roya",
    0xA0: "lshift",
    0xA1: "rshift",
    0xA2: "lcontrol",
    0xA3: "rcontrol",
    0xA4: "lmenu",
    0xA5: "rmenu",
    0xA6: "browser_back",
    0xA7: "browser_forward",
    0xA8: "browser_refresh",
    0xA9: "browser_stop",
    0xAA: "browser_search",
    0xAB: "browser_favorites",
    0xAC: "browser_home",
    0xAD: "volume_mute",
    0xAE: "volume_down",
    0xAF: "volume_up",
    0xB0: "media_next_track",
    0xB1: "media_prev_track",
    0xB2: "media_stop",
    0xB3: "media_play_pause",
    0xB4: "launch_mail",
    0xB5: "launch_media_select",
    0xB6: "launch_app1",
    0xB7: "launch_app2",
    0xBA: "oem_1",
    0xBB: "oem_plus",
    0xBC: "oem_comma",
    0xBD: "oem_minus",
    0xBE: "oem_period",
    0xBF: "oem_2",
    0xC0: "oem_3",
    0xC3: "gamepad_a",
    0xC4: "gamepad_b",
    0xC5: "gamepad_x",
    0xC6: "gamepad_y",
    0xC7: "gamepad_right_shoulder",
    0xC8: "gamepad_left_shoulder",
    0xC9: "gamepad_left_trigger",
    0xCA: "gamepad_right_trigger",
    0xCB: "gamepad_dpad_up",
    0xCC: "gamepad_dpad_down",
    0xCD: "gamepad_dpad_left",
    0xCE: "gamepad_dpad_right",
    0xCF: "gamepad_menu",
    0xD0: "gamepad_view",
    0xD1: "gamepad_left_thumbstick_button",
    0xD2: "gamepad_right_thumbstick_button",
    0xD3: "gamepad_left_thumbstick_up",
    0xD4: "gamepad_left_thumbstick_down",
    0xD5: "gamepad_left_thumbstick_right",
    0xD6: "gamepad_left_thumbstick_left",
    0xD7: "gamepad_right_thumbstick_up",
    0xD8: "gamepad_right_thumbstick_down",
    0xD9: "gamepad_right_thumbstick_right",
    0xDA: "gamepad_right_thumbstick_left",
    0xDB: "oem_4",
    0xDC: "oem_5",
    0xDD: "oem_6",
    0xDE: "oem_7",
    0xDF: "oem_8",
    0xE1: "oem_ax",
    0xE2: "oem_102",
    0xE3: "ico_help",
    0xE4: "ico_00",
    0xE5: "processkey",
    0xE6: "ico_clear",
    0xE7: "packet",
    0xE9: "oem_reset",
    0xEA: "oem_jump",
    0xEB: "oem_pa1",
    0xEC: "oem_pa2",
    0xED: "oem_pa3",
    0xEE: "oem_wsctrl",
    0xEF: "oem_cusel",
    0xF0: "oem_attn",
    0xF1: "oem_finish",
    0xF2: "oem_copy",
    0xF3: "oem_auto",
    0xF4: "oem_enlw",
    0xF5: "oem_backtab",
    0xF6: "attn",
    0xF7: "crsel",
    0xF8: "exsel",
    0xF9: "ereof",
    0xFA: "play",
    0xFB: "zoom",
    0xFC: "noname",
    0xFD: "pa1",
    0xFE: "oem_clear",
}

var WebviewWindowDefaults = &WebviewWindowOptions{
    Title:  "",
    Width:  800,
    Height: 600,
    URL:    "",
    BackgroundColour: RGBA{
        Red:   255,
        Green: 255,
        Blue:  255,
        Alpha: 255,
    },
}

func DefaultLogger

func DefaultLogger(level slog.Level) *slog.Logger

func Fatal

func Fatal(message string, args ...interface{})

func InvokeAsync

func InvokeAsync(fn func())

func InvokeSync

func InvokeSync(fn func())

func InvokeSyncWithError

func InvokeSyncWithError(fn func() error) (err error)

func InvokeSyncWithResult

func InvokeSyncWithResult[T any](fn func() T) (res T)

func InvokeSyncWithResultAndError

func InvokeSyncWithResultAndError[T any](fn func() (T, error)) (res T, err error)

func NewIconFromResource

func NewIconFromResource(instance w32.HINSTANCE, resId uint16) (w32.HICON, error)

func ScaleToDefaultDPI

func ScaleToDefaultDPI(pixels int, dpi uint) int

func ScaleWithDPI

func ScaleWithDPI(pixels int, dpi uint) int

type ActivationPolicy

ActivationPolicy is the activation policy for the application.

type ActivationPolicy int

const (
    // ActivationPolicyRegular is used for applications that have a user interface,
    ActivationPolicyRegular ActivationPolicy = iota
    // ActivationPolicyAccessory is used for applications that do not have a main window,
    // such as system tray applications or background applications.
    ActivationPolicyAccessory
    ActivationPolicyProhibited
)

type App

type App struct {

    // The main application menu
    ApplicationMenu *Menu

    Events *EventProcessor
    Logger *slog.Logger
    // contains filtered or unexported fields
}

func Get

func Get() *App

func New

func New(appOptions Options) *App

func \*App Capabilities

func (a *App) Capabilities() capabilities.Capabilities

func \*App Clipboard

func (a *App) Clipboard() *Clipboard

func \*App CurrentWindow

func (a *App) CurrentWindow() *WebviewWindow

func \*App GetPID

func (a *App) GetPID() int

func \*App GetPrimaryScreen

func (a *App) GetPrimaryScreen() (*Screen, error)

func \*App GetScreens

func (a *App) GetScreens() ([]*Screen, error)

func \*App GetWindowByName

func (a *App) GetWindowByName(name string) *WebviewWindow

func \*App Hide

func (a *App) Hide()

func \*App IsDarkMode

func (a *App) IsDarkMode() bool

func \*App NewMenu

func (a *App) NewMenu() *Menu

func \*App NewSystemTray

func (a *App) NewSystemTray() *SystemTray

func \*App NewWebviewWindow

func (a *App) NewWebviewWindow() *WebviewWindow

func \*App NewWebviewWindowWithOptions

func (a *App) NewWebviewWindowWithOptions(windowOptions WebviewWindowOptions) *WebviewWindow

func \*App On

func (a *App) On(eventType events.ApplicationEventType, callback func(event *Event)) func()

func \*App OnWindowCreation

func (a *App) OnWindowCreation(callback func(window *WebviewWindow))

func \*App Quit

func (a *App) Quit()

func \*App RegisterContextMenu

func (a *App) RegisterContextMenu(name string, menu *Menu)

func \*App RegisterHook

func (a *App) RegisterHook(eventType events.ApplicationEventType, callback func(event *Event)) func()

RegisterHook registers a hook for the given event type. Hooks are called before the event listeners and can cancel the event. The returned function can be called to remove the hook.

func \*App Run

func (a *App) Run() error

func \*App SetMenu

func (a *App) SetMenu(menu *Menu)

func \*App Show

func (a *App) Show()

func \*App ShowAboutDialog

func (a *App) ShowAboutDialog()

type ApplicationEventContext

type ApplicationEventContext struct {
    // contains filtered or unexported fields
}

func ApplicationEventContext IsDarkMode

func (c ApplicationEventContext) IsDarkMode() bool

func ApplicationEventContext OpenedFiles

func (c ApplicationEventContext) OpenedFiles() []string

type Args

type Args struct {
    // contains filtered or unexported fields
}

func \*Args Bool

func (a *Args) Bool(s string) *bool

func \*Args Float64

func (a *Args) Float64(s string) *float64

func \*Args Int

func (a *Args) Int(s string) *int

func \*Args String

func (a *Args) String(key string) *string

func \*Args UInt

func (a *Args) UInt(s string) *uint

func \*Args UInt8

func (a *Args) UInt8(s string) *uint8

type AssetOptions

AssetOptions defines the configuration of the AssetServer.

type AssetOptions struct {
    // Handler which serves all the content to the WebView.
	Handler http.Handler

	// Middleware is a HTTP Middleware which allows to hook into the AssetServer request chain. It allows to skip the default
	// request handler dynamically, e.g. implement specialized Routing etc.
	// The Middleware is called to build a new `http.Handler` used by the AssetSever and it also receives the default
	// handler used by the AssetServer as an argument.
	//
	// This middleware injects itself before any of Wails internal middlewares.
	//
	// If not defined, the default AssetServer request chain is executed.
	//
	// Multiple Middlewares can be chained together with:
	//   ChainMiddleware(middleware ...Middleware) Middleware
	Middleware Middleware

    // External URL can be set to a development server URL so that all requests are forwarded to it. This is useful
    // when using a development server like `vite` or `snowpack` which serves the assets on a different port.
    ExternalURL string
}

type BackdropType

type BackdropType int32

const (
    Auto    BackdropType = 0
    None    BackdropType = 1
    Mica    BackdropType = 2
    Acrylic BackdropType = 3
    Tabbed  BackdropType = 4
)

type BackgroundType

type BackgroundType int

const (
    BackgroundTypeSolid BackgroundType = iota
    BackgroundTypeTransparent
    BackgroundTypeTranslucent
)

type Bindings

type Bindings struct {
    // contains filtered or unexported fields
}

func NewBindings

func NewBindings(structs []any, aliases map[uint32]uint32) (*Bindings, error)

func \*Bindings Add

func (b *Bindings) Add(structPtr interface{}) error

Add the given struct methods to the Bindings

func \*Bindings AddPlugins

func (b *Bindings) AddPlugins(plugins map[string]Plugin) error

func \*Bindings GenerateID

func (b *Bindings) GenerateID(name string) (uint32, error)

GenerateID generates a unique ID for a binding

func \*Bindings Get

func (b *Bindings) Get(options *CallOptions) *BoundMethod

Get returns the bound method with the given name

func \*Bindings GetByID

func (b *Bindings) GetByID(id uint32) *BoundMethod

GetByID returns the bound method with the given ID

type BoundMethod

BoundMethod defines all the data related to a Go method that is bound to the Wails application

type BoundMethod struct {
    ID          uint32        `json:"id"`
    Name        string        `json:"name"`
    Inputs      []*Parameter  `json:"inputs,omitempty"`
    Outputs     []*Parameter  `json:"outputs,omitempty"`
    Comments    string        `json:"comments,omitempty"`
    Method      reflect.Value `json:"-"`
    PackageName string
    StructName  string
    PackagePath string
}

func \*BoundMethod Call

func (b *BoundMethod) Call(args []interface{}) (returnValue interface{}, err error)

Call will attempt to call this bound method with the given args

func \*BoundMethod String

func (b *BoundMethod) String() string

type Button

type Button struct {
    Label     string
    IsCancel  bool
    IsDefault bool
    Callback  func()
}

func \*Button OnClick

func (b *Button) OnClick(callback func()) *Button

func \*Button SetAsCancel

func (b *Button) SetAsCancel() *Button

func \*Button SetAsDefault

func (b *Button) SetAsDefault() *Button

type CallOptions

type CallOptions struct {
    MethodID    uint32 `json:"methodID"`
    PackageName string `json:"packageName"`
    StructName  string `json:"structName"`
    MethodName  string `json:"methodName"`
    Args        []any  `json:"args"`
}

func CallOptions Name

func (c CallOptions) Name() string

type Clipboard

type Clipboard struct {
    // contains filtered or unexported fields
}

func \*Clipboard SetText

func (c *Clipboard) SetText(text string) bool

func \*Clipboard Text

func (c *Clipboard) Text() (string, bool)

type Context

type Context struct {
    // contains filtered or unexported fields
}

func \*Context ClickedMenuItem

func (c *Context) ClickedMenuItem() *MenuItem

func \*Context ContextMenuData

func (c *Context) ContextMenuData() any

func \*Context IsChecked

func (c *Context) IsChecked() bool

type ContextMenuData

type ContextMenuData struct {
    Id   string `json:"id"`
    X    int    `json:"x"`
    Y    int    `json:"y"`
    Data any    `json:"data"`
}

type DialogType

type DialogType int

const (
    InfoDialogType DialogType = iota
    QuestionDialogType
    WarningDialogType
    ErrorDialogType
    OpenDirectoryDialogType
)

type Event

type Event struct {
    Id  uint

    Cancelled bool
    // contains filtered or unexported fields
}

func \*Event Cancel

func (w *Event) Cancel()

func \*Event Context

func (w *Event) Context() *ApplicationEventContext

type EventListener

type EventListener struct {
    // contains filtered or unexported fields
}

type EventProcessor

EventProcessor handles custom events

type EventProcessor struct {
    // contains filtered or unexported fields
}

func NewWailsEventProcessor

func NewWailsEventProcessor(dispatchEventToWindows func(*WailsEvent)) *EventProcessor

func \*EventProcessor Emit

func (e *EventProcessor) Emit(thisEvent *WailsEvent)

Emit sends an event to all listeners

func \*EventProcessor Off

func (e *EventProcessor) Off(eventName string)

func \*EventProcessor OffAll

func (e *EventProcessor) OffAll()

func \*EventProcessor On

func (e *EventProcessor) On(eventName string, callback func(event *WailsEvent)) func()

On is the equivalent of Javascript's `addEventListener`

func \*EventProcessor OnMultiple

func (e *EventProcessor) OnMultiple(eventName string, callback func(event *WailsEvent), counter int) func()

OnMultiple is the same as `On` but will unregister after `count` events

func \*EventProcessor Once

func (e *EventProcessor) Once(eventName string, callback func(event *WailsEvent)) func()

Once is the same as `On` but will unregister after the first event

func \*EventProcessor RegisterHook

func (e *EventProcessor) RegisterHook(eventName string, callback func(*WailsEvent)) func()

RegisterHook provides a means of registering methods to be called before emitting the event

type FileFilter

type FileFilter struct {
    DisplayName string // Filter information EG: "Image Files (*.jpg, *.png)"
    Pattern     string // semicolon separated list of extensions, EG: "*.jpg;*.png"
}

type IconPosition

type IconPosition int

type MacAppearanceType

MacAppearanceType is a type of Appearance for Cocoa windows

type MacAppearanceType string

const (
    // DefaultAppearance uses the default system value
    DefaultAppearance MacAppearanceType = ""
    // NSAppearanceNameAqua - The standard light system appearance.
    NSAppearanceNameAqua MacAppearanceType = "NSAppearanceNameAqua"
    // NSAppearanceNameDarkAqua - The standard dark system appearance.
    NSAppearanceNameDarkAqua MacAppearanceType = "NSAppearanceNameDarkAqua"
    // NSAppearanceNameVibrantLight - The light vibrant appearance
    NSAppearanceNameVibrantLight MacAppearanceType = "NSAppearanceNameVibrantLight"
    // NSAppearanceNameAccessibilityHighContrastAqua - A high-contrast version of the standard light system appearance.
    NSAppearanceNameAccessibilityHighContrastAqua MacAppearanceType = "NSAppearanceNameAccessibilityHighContrastAqua"
    // NSAppearanceNameAccessibilityHighContrastDarkAqua - A high-contrast version of the standard dark system appearance.
    NSAppearanceNameAccessibilityHighContrastDarkAqua MacAppearanceType = "NSAppearanceNameAccessibilityHighContrastDarkAqua"
    // NSAppearanceNameAccessibilityHighContrastVibrantLight - A high-contrast version of the light vibrant appearance.
    NSAppearanceNameAccessibilityHighContrastVibrantLight MacAppearanceType = "NSAppearanceNameAccessibilityHighContrastVibrantLight"
    // NSAppearanceNameAccessibilityHighContrastVibrantDark - A high-contrast version of the dark vibrant appearance.
    NSAppearanceNameAccessibilityHighContrastVibrantDark MacAppearanceType = "NSAppearanceNameAccessibilityHighContrastVibrantDark"
)

type MacBackdrop

MacBackdrop is the backdrop type for macOS

type MacBackdrop int

const (
    // MacBackdropNormal - The default value. The window will have a normal opaque background.
    MacBackdropNormal MacBackdrop = iota
    // MacBackdropTransparent - The window will have a transparent background, with the content underneath it being visible
    MacBackdropTransparent
    // MacBackdropTranslucent - The window will have a translucent background, with the content underneath it being "fuzzy" or "frosted"
    MacBackdropTranslucent
)

type MacOptions

MacOptions contains options for macOS applications.

type MacOptions struct {
    // ActivationPolicy is the activation policy for the application. Defaults to
    // applicationActivationPolicyRegular.
    ActivationPolicy ActivationPolicy
    // If set to true, the application will terminate when the last window is closed.
    ApplicationShouldTerminateAfterLastWindowClosed bool
}

type MacTitleBar

MacTitleBar contains options for the Mac titlebar

type MacTitleBar struct {
    // AppearsTransparent will make the titlebar transparent
    AppearsTransparent bool
    // Hide will hide the titlebar
    Hide bool
    // HideTitle will hide the title
    HideTitle bool
    // FullSizeContent will extend the window content to the full size of the window
    FullSizeContent bool
    // UseToolbar will use a toolbar instead of a titlebar
    UseToolbar bool
    // HideToolbarSeparator will hide the toolbar separator
    HideToolbarSeparator bool
    // ShowToolbarWhenFullscreen will keep the toolbar visible when the window is in fullscreen mode
	ShowToolbarWhenFullscreen bool
    // ToolbarStyle is the style of toolbar to use
    ToolbarStyle MacToolbarStyle
}

type MacToolbarStyle

MacToolbarStyle is the style of toolbar for macOS

type MacToolbarStyle int

const (
    // MacToolbarStyleAutomatic - The default value. The style will be determined by the window's given configuration
    MacToolbarStyleAutomatic MacToolbarStyle = iota
    // MacToolbarStyleExpanded - The toolbar will appear below the window title
    MacToolbarStyleExpanded
    // MacToolbarStylePreference - The toolbar will appear below the window title and the items in the toolbar will attempt to have equal widths when possible
    MacToolbarStylePreference
    // MacToolbarStyleUnified - The window title will appear inline with the toolbar when visible
    MacToolbarStyleUnified
    // MacToolbarStyleUnifiedCompact - Same as MacToolbarStyleUnified, but with reduced margins in the toolbar allowing more focus to be on the contents of the window
    MacToolbarStyleUnifiedCompact
)

type MacWindow

MacWindow contains macOS specific options for Webview Windows

type MacWindow struct {
    // Backdrop is the backdrop type for the window
    Backdrop MacBackdrop
    // DisableShadow will disable the window shadow
    DisableShadow bool
    // TitleBar contains options for the Mac titlebar
    TitleBar MacTitleBar
    // Appearance is the appearance type for the window
    Appearance MacAppearanceType
    // InvisibleTitleBarHeight defines the height of an invisible titlebar which responds to dragging
    InvisibleTitleBarHeight int
    // Maps events from platform specific to common event types
    EventMapping map[events.WindowEventType]events.WindowEventType

    // EnableFraudulentWebsiteWarnings will enable warnings for fraudulent websites.
    // Default: false
    EnableFraudulentWebsiteWarnings bool
}

type Menu

type Menu struct {
    // contains filtered or unexported fields
}

func NewMenu

func NewMenu() *Menu

func \*Menu Add

func (m *Menu) Add(label string) *MenuItem

func \*Menu AddCheckbox

func (m *Menu) AddCheckbox(label string, enabled bool) *MenuItem

func \*Menu AddRadio

func (m *Menu) AddRadio(label string, enabled bool) *MenuItem

func \*Menu AddRole

func (m *Menu) AddRole(role Role) *Menu

func \*Menu AddSeparator

func (m *Menu) AddSeparator()

func \*Menu AddSubmenu

func (m *Menu) AddSubmenu(s string) *Menu

func \*Menu SetLabel

func (m *Menu) SetLabel(label string)

func \*Menu Update

func (m *Menu) Update()

type MenuItem

type MenuItem struct {
    // contains filtered or unexported fields
}

func \*MenuItem Checked

func (m *MenuItem) Checked() bool

func \*MenuItem Enabled

func (m *MenuItem) Enabled() bool

func \*MenuItem Hidden

func (m *MenuItem) Hidden() bool

func \*MenuItem IsCheckbox

func (m *MenuItem) IsCheckbox() bool

func \*MenuItem IsRadio

func (m *MenuItem) IsRadio() bool

func \*MenuItem IsSeparator

func (m *MenuItem) IsSeparator() bool

func \*MenuItem IsSubmenu

func (m *MenuItem) IsSubmenu() bool

func \*MenuItem Label

func (m *MenuItem) Label() string

func \*MenuItem OnClick

func (m *MenuItem) OnClick(f func(*Context)) *MenuItem

func \*MenuItem SetAccelerator

func (m *MenuItem) SetAccelerator(shortcut string) *MenuItem

func \*MenuItem SetChecked

func (m *MenuItem) SetChecked(checked bool) *MenuItem

func \*MenuItem SetEnabled

func (m *MenuItem) SetEnabled(enabled bool) *MenuItem

func \*MenuItem SetHidden

func (m *MenuItem) SetHidden(hidden bool) *MenuItem

func \*MenuItem SetLabel

func (m *MenuItem) SetLabel(s string) *MenuItem

func \*MenuItem SetTooltip

func (m *MenuItem) SetTooltip(s string) *MenuItem

func \*MenuItem Tooltip

func (m *MenuItem) Tooltip() string

type MessageDialog

type MessageDialog struct {
    MessageDialogOptions
    // contains filtered or unexported fields
}

func ErrorDialog

func ErrorDialog() *MessageDialog

func InfoDialog

func InfoDialog() *MessageDialog

func OpenDirectoryDialog

func OpenDirectoryDialog() *MessageDialog

func QuestionDialog

func QuestionDialog() *MessageDialog

func WarningDialog

func WarningDialog() *MessageDialog

func \*MessageDialog AddButton

func (d *MessageDialog) AddButton(s string) *Button

func \*MessageDialog AddButtons

func (d *MessageDialog) AddButtons(buttons []*Button) *MessageDialog

func \*MessageDialog AttachToWindow

func (d *MessageDialog) AttachToWindow(window *WebviewWindow) *MessageDialog

func \*MessageDialog SetCancelButton

func (d *MessageDialog) SetCancelButton(button *Button) *MessageDialog

func \*MessageDialog SetDefaultButton

func (d *MessageDialog) SetDefaultButton(button *Button) *MessageDialog

func \*MessageDialog SetIcon

func (d *MessageDialog) SetIcon(icon []byte) *MessageDialog

func \*MessageDialog SetMessage

func (d *MessageDialog) SetMessage(message string) *MessageDialog

func \*MessageDialog SetTitle

func (d *MessageDialog) SetTitle(title string) *MessageDialog

func \*MessageDialog Show

func (d *MessageDialog) Show()

type MessageDialogOptions

type MessageDialogOptions struct {
    DialogType DialogType
    Title      string
    Message    string
    Buttons    []*Button
    Icon       []byte
    // contains filtered or unexported fields
}

type MessageProcessor

type MessageProcessor struct {
    // contains filtered or unexported fields
}

func NewMessageProcessor

func NewMessageProcessor(logger *slog.Logger) *MessageProcessor

func \*MessageProcessor Error

func (m *MessageProcessor) Error(message string, args ...any)

func \*MessageProcessor HandleRuntimeCall

func (m *MessageProcessor) HandleRuntimeCall(rw http.ResponseWriter, r *http.Request)

func \*MessageProcessor HandleRuntimeCallWithIDs

func (m *MessageProcessor) HandleRuntimeCallWithIDs(rw http.ResponseWriter, r *http.Request)

func \*MessageProcessor Info

func (m *MessageProcessor) Info(message string, args ...any)

type Middleware

Middleware defines HTTP middleware that can be applied to the AssetServer. The handler passed as next is the next handler in the chain. One can decide to call the next handler or implement a specialized handling.

type Middleware func(next http.Handler) http.Handler

func ChainMiddleware

func ChainMiddleware(middleware ...Middleware) Middleware

ChainMiddleware allows chaining multiple middlewares to one middleware.

type OpenFileDialogOptions

type OpenFileDialogOptions struct {
    CanChooseDirectories            bool
    CanChooseFiles                  bool
    CanCreateDirectories            bool
    ShowHiddenFiles                 bool
    ResolvesAliases                 bool
    AllowsMultipleSelection         bool
    HideExtension                   bool
    CanSelectHiddenExtension        bool
    TreatsFilePackagesAsDirectories bool
    AllowsOtherFileTypes            bool
    Filters                         []FileFilter
    Window                          *WebviewWindow

    Title      string
    Message    string
    ButtonText string
    Directory  string
}

type OpenFileDialogStruct

type OpenFileDialogStruct struct {
    // contains filtered or unexported fields
}

func OpenFileDialog

func OpenFileDialog() *OpenFileDialogStruct

func OpenFileDialogWithOptions

func OpenFileDialogWithOptions(options *OpenFileDialogOptions) *OpenFileDialogStruct

func \*OpenFileDialogStruct AddFilter

func (d *OpenFileDialogStruct) AddFilter(displayName, pattern string) *OpenFileDialogStruct

AddFilter adds a filter to the dialog. The filter is a display name and a semicolon separated list of extensions. EG: AddFilter("Image Files", "*.jpg;*.png")

func \*OpenFileDialogStruct AllowsOtherFileTypes

func (d *OpenFileDialogStruct) AllowsOtherFileTypes(allowsOtherFileTypes bool) *OpenFileDialogStruct

func \*OpenFileDialogStruct AttachToWindow

func (d *OpenFileDialogStruct) AttachToWindow(window *WebviewWindow) *OpenFileDialogStruct

func \*OpenFileDialogStruct CanChooseDirectories

func (d *OpenFileDialogStruct) CanChooseDirectories(canChooseDirectories bool) *OpenFileDialogStruct

func \*OpenFileDialogStruct CanChooseFiles

func (d *OpenFileDialogStruct) CanChooseFiles(canChooseFiles bool) *OpenFileDialogStruct

func \*OpenFileDialogStruct CanCreateDirectories

func (d *OpenFileDialogStruct) CanCreateDirectories(canCreateDirectories bool) *OpenFileDialogStruct

func \*OpenFileDialogStruct CanSelectHiddenExtension

func (d *OpenFileDialogStruct) CanSelectHiddenExtension(canSelectHiddenExtension bool) *OpenFileDialogStruct

func \*OpenFileDialogStruct HideExtension

func (d *OpenFileDialogStruct) HideExtension(hideExtension bool) *OpenFileDialogStruct

func \*OpenFileDialogStruct PromptForMultipleSelection

func (d *OpenFileDialogStruct) PromptForMultipleSelection() ([]string, error)

func \*OpenFileDialogStruct PromptForSingleSelection

func (d *OpenFileDialogStruct) PromptForSingleSelection() (string, error)

func \*OpenFileDialogStruct ResolvesAliases

func (d *OpenFileDialogStruct) ResolvesAliases(resolvesAliases bool) *OpenFileDialogStruct

func \*OpenFileDialogStruct SetButtonText

func (d *OpenFileDialogStruct) SetButtonText(text string) *OpenFileDialogStruct

func \*OpenFileDialogStruct SetDirectory

func (d *OpenFileDialogStruct) SetDirectory(directory string) *OpenFileDialogStruct

func \*OpenFileDialogStruct SetMessage

func (d *OpenFileDialogStruct) SetMessage(message string) *OpenFileDialogStruct

func \*OpenFileDialogStruct SetOptions

func (d *OpenFileDialogStruct) SetOptions(options *OpenFileDialogOptions)

func \*OpenFileDialogStruct SetTitle

func (d *OpenFileDialogStruct) SetTitle(title string) *OpenFileDialogStruct

func \*OpenFileDialogStruct ShowHiddenFiles

func (d *OpenFileDialogStruct) ShowHiddenFiles(showHiddenFiles bool) *OpenFileDialogStruct

func \*OpenFileDialogStruct TreatsFilePackagesAsDirectories

func (d *OpenFileDialogStruct) TreatsFilePackagesAsDirectories(treatsFilePackagesAsDirectories bool) *OpenFileDialogStruct

type Options

type Options struct {
    // Name is the name of the application
    Name string

    // Description is the description of the application (used in the default about box)
    Description string

    // Icon is the icon of the application (used in the default about box)
    Icon []byte

    // Mac is the Mac specific configuration for Mac builds
    Mac MacOptions

    // Windows is the Windows specific configuration for Windows builds
    Windows WindowsOptions

    // Bind allows you to bind Go methods to the frontend.
    Bind []any

    // BindAliases allows you to specify alias IDs for your bound methods.
    // Example: `BindAliases: map[uint32]uint32{1: 1411160069}` states that alias ID 1 maps to the Go method with ID 1411160069.
    BindAliases map[uint32]uint32

    // Logger i a slog.Logger instance used for logging Wails system messages (not application messages).
    // If not defined, a default logger is used.
    Logger *slog.Logger

    // LogLevel defines the log level of the Wails system logger.
    LogLevel slog.Level

    // Assets are the application assets to be used.
    Assets AssetOptions

    // Plugins is a map of plugins used by the application
    Plugins map[string]Plugin

    // Flags are key value pairs that are available to the frontend.
    // This is also used by Wails to provide information to the frontend.
    Flags map[string]any

    // PanicHandler is a way to register a custom panic handler
    PanicHandler func(any)

    // KeyBindings is a map of key bindings to functions
    KeyBindings map[string]func(window *WebviewWindow)
}

type Parameter

Parameter defines a Go method parameter

type Parameter struct {
    Name        string `json:"name,omitempty"`
    TypeName    string `json:"type"`
    ReflectType reflect.Type
}

func \*Parameter IsError

func (p *Parameter) IsError() bool

IsError returns true if the parameter type is an error

func \*Parameter IsType

func (p *Parameter) IsType(typename string) bool

IsType returns true if the given

type Plugin

type Plugin interface {
    Name() string
    Init() error
    Shutdown()
    CallableByJS() []string
    InjectJS() string
}

type PluginCallOptions

type PluginCallOptions struct {
    Name string `json:"name"`
    Args []any  `json:"args"`
}

type PluginManager

type PluginManager struct {
    // contains filtered or unexported fields
}

func NewPluginManager

func NewPluginManager(plugins map[string]Plugin, assetServer *assetserver.AssetServer) *PluginManager

func \*PluginManager Init

func (p *PluginManager) Init() error

func \*PluginManager Shutdown

func (p *PluginManager) Shutdown()

type PositionOptions

type PositionOptions struct {
    Buffer int
}

type QueryParams

type QueryParams map[string][]string

func QueryParams Args

func (qp QueryParams) Args() (*Args, error)

func QueryParams Bool

func (qp QueryParams) Bool(key string) *bool

func QueryParams Float64

func (qp QueryParams) Float64(key string) *float64

func QueryParams Int

func (qp QueryParams) Int(key string) *int

func QueryParams String

func (qp QueryParams) String(key string) *string

func QueryParams ToStruct

func (qp QueryParams) ToStruct(str any) error

func QueryParams UInt

func (qp QueryParams) UInt(key string) *uint

func QueryParams UInt8

func (qp QueryParams) UInt8(key string) *uint8

type RGBA

type RGBA struct {
    Red, Green, Blue, Alpha uint8
}

type RadioGroup

type RadioGroup []*RadioGroupMember

func \*RadioGroup Add

func (r *RadioGroup) Add(id int, item *MenuItem)

func \*RadioGroup Bounds

func (r *RadioGroup) Bounds() (int, int)

func \*RadioGroup MenuID

func (r *RadioGroup) MenuID(item *MenuItem) int

type RadioGroupMember

type RadioGroupMember struct {
    ID       int
    MenuItem *MenuItem
}

type Rect

type Rect struct {
    X      int
    Y      int
    Width  int
    Height int
}

type Role

Role is a type to identify menu roles

type Role uint

These constants need to be kept in sync with `v2/internal/frontend/desktop/darwin/Role.h`

const (
    NoRole       Role = iota
    AppMenu      Role = iota
    EditMenu     Role = iota
    ViewMenu     Role = iota
    WindowMenu   Role = iota
    ServicesMenu Role = iota
    HelpMenu     Role = iota

    Hide               Role = iota
    HideOthers         Role = iota
    UnHide             Role = iota
    About              Role = iota
    Undo               Role = iota
    Redo               Role = iota
    Cut                Role = iota
    Copy               Role = iota
    Paste              Role = iota
    PasteAndMatchStyle Role = iota
    SelectAll          Role = iota
    Delete             Role = iota
    SpeechMenu         Role = iota
    Quit               Role = iota
    FileMenu           Role = iota
    Close              Role = iota
    Reload             Role = iota
    ForceReload        Role = iota
    ToggleDevTools     Role = iota
    ResetZoom          Role = iota
    ZoomIn             Role = iota
    ZoomOut            Role = iota
    ToggleFullscreen   Role = iota

    Minimize   Role = iota
    Zoom       Role = iota
    FullScreen Role = iota
)

type SaveFileDialogOptions

type SaveFileDialogOptions struct {
    CanCreateDirectories            bool
    ShowHiddenFiles                 bool
    CanSelectHiddenExtension        bool
    AllowOtherFileTypes             bool
    HideExtension                   bool
    TreatsFilePackagesAsDirectories bool
    Title                           string
    Message                         string
    Directory                       string
    Filename                        string
    ButtonText                      string
    Filters                         []FileFilter
    Window                          *WebviewWindow
}

type SaveFileDialogStruct

type SaveFileDialogStruct struct {
    // contains filtered or unexported fields
}

func SaveFileDialog

func SaveFileDialog() *SaveFileDialogStruct

func SaveFileDialogWithOptions

func SaveFileDialogWithOptions(s *SaveFileDialogOptions) *SaveFileDialogStruct

func \*SaveFileDialogStruct AddFilter

func (d *SaveFileDialogStruct) AddFilter(displayName, pattern string) *SaveFileDialogStruct

AddFilter adds a filter to the dialog. The filter is a display name and a semicolon separated list of extensions. EG: AddFilter("Image Files", "*.jpg;*.png")

func \*SaveFileDialogStruct AllowsOtherFileTypes

func (d *SaveFileDialogStruct) AllowsOtherFileTypes(allowOtherFileTypes bool) *SaveFileDialogStruct

func \*SaveFileDialogStruct AttachToWindow

func (d *SaveFileDialogStruct) AttachToWindow(window *WebviewWindow) *SaveFileDialogStruct

func \*SaveFileDialogStruct CanCreateDirectories

func (d *SaveFileDialogStruct) CanCreateDirectories(canCreateDirectories bool) *SaveFileDialogStruct

func \*SaveFileDialogStruct CanSelectHiddenExtension

func (d *SaveFileDialogStruct) CanSelectHiddenExtension(canSelectHiddenExtension bool) *SaveFileDialogStruct

func \*SaveFileDialogStruct HideExtension

func (d *SaveFileDialogStruct) HideExtension(hideExtension bool) *SaveFileDialogStruct

func \*SaveFileDialogStruct PromptForSingleSelection

func (d *SaveFileDialogStruct) PromptForSingleSelection() (string, error)

func \*SaveFileDialogStruct SetButtonText

func (d *SaveFileDialogStruct) SetButtonText(text string) *SaveFileDialogStruct

func \*SaveFileDialogStruct SetDirectory

func (d *SaveFileDialogStruct) SetDirectory(directory string) *SaveFileDialogStruct

func \*SaveFileDialogStruct SetFilename

func (d *SaveFileDialogStruct) SetFilename(filename string) *SaveFileDialogStruct

func \*SaveFileDialogStruct SetMessage

func (d *SaveFileDialogStruct) SetMessage(message string) *SaveFileDialogStruct

func \*SaveFileDialogStruct SetOptions

func (d *SaveFileDialogStruct) SetOptions(options *SaveFileDialogOptions)

func \*SaveFileDialogStruct ShowHiddenFiles

func (d *SaveFileDialogStruct) ShowHiddenFiles(showHiddenFiles bool) *SaveFileDialogStruct

func \*SaveFileDialogStruct TreatsFilePackagesAsDirectories

func (d *SaveFileDialogStruct) TreatsFilePackagesAsDirectories(treatsFilePackagesAsDirectories bool) *SaveFileDialogStruct

type Screen

type Screen struct {
    ID        string  // A unique identifier for the display
    Name      string  // The name of the display
    Scale     float32 // The scale factor of the display
    X         int     // The x-coordinate of the top-left corner of the rectangle
    Y         int     // The y-coordinate of the top-left corner of the rectangle
    Size      Size    // The size of the display
    Bounds    Rect    // The bounds of the display
    WorkArea  Rect    // The work area of the display
    IsPrimary bool    // Whether this is the primary display
    Rotation  float32 // The rotation of the display
}

type Size

type Size struct {
    Width  int
    Height int
}

type SystemTray

type SystemTray struct {
    // contains filtered or unexported fields
}

func \*SystemTray AttachWindow

func (s *SystemTray) AttachWindow(window *WebviewWindow) *SystemTray

AttachWindow attaches a window to the system tray. The window will be shown when the system tray icon is clicked. The window will be hidden when the system tray icon is clicked again, or when the window loses focus.

func \*SystemTray Destroy

func (s *SystemTray) Destroy()

func \*SystemTray Label

func (s *SystemTray) Label() string

func \*SystemTray OnClick

func (s *SystemTray) OnClick(handler func()) *SystemTray

func \*SystemTray OnDoubleClick

func (s *SystemTray) OnDoubleClick(handler func()) *SystemTray

func \*SystemTray OnMouseEnter

func (s *SystemTray) OnMouseEnter(handler func()) *SystemTray

func \*SystemTray OnMouseLeave

func (s *SystemTray) OnMouseLeave(handler func()) *SystemTray

func \*SystemTray OnRightClick

func (s *SystemTray) OnRightClick(handler func()) *SystemTray

func \*SystemTray OnRightDoubleClick

func (s *SystemTray) OnRightDoubleClick(handler func()) *SystemTray

func \*SystemTray OpenMenu

func (s *SystemTray) OpenMenu()

func \*SystemTray PositionWindow

func (s *SystemTray) PositionWindow(window *WebviewWindow, offset int) error

func \*SystemTray SetDarkModeIcon

func (s *SystemTray) SetDarkModeIcon(icon []byte) *SystemTray

func \*SystemTray SetIcon

func (s *SystemTray) SetIcon(icon []byte) *SystemTray

func \*SystemTray SetIconPosition

func (s *SystemTray) SetIconPosition(iconPosition int) *SystemTray

func \*SystemTray SetLabel

func (s *SystemTray) SetLabel(label string)

func \*SystemTray SetMenu

func (s *SystemTray) SetMenu(menu *Menu) *SystemTray

func \*SystemTray SetTemplateIcon

func (s *SystemTray) SetTemplateIcon(icon []byte) *SystemTray

func \*SystemTray WindowDebounce

func (s *SystemTray) WindowDebounce(debounce time.Duration) *SystemTray

WindowDebounce is used by Windows to indicate how long to wait before responding to a mouse up event on the notification icon. This prevents the window from being hidden and then immediately shown when the user clicks on the system tray icon. See https://stackoverflow.com/questions/4585283/alternate-showing-hiding-window-when-notify-icon-is-clicked

func \*SystemTray WindowOffset

func (s *SystemTray) WindowOffset(offset int) *SystemTray

WindowOffset sets the gap in pixels between the system tray and the window

type Theme

type Theme int

const (
    // SystemDefault will use whatever the system theme is. The application will follow system theme changes.
    SystemDefault Theme = 0
    // Dark Mode
    Dark Theme = 1
    // Light Mode
    Light Theme = 2
)

type ThemeSettings

ThemeSettings defines custom colours to use in dark or light mode. They may be set using the hex values: 0x00BBGGRR

type ThemeSettings struct {
    DarkModeTitleBar           int32
    DarkModeTitleBarInactive   int32
    DarkModeTitleText          int32
    DarkModeTitleTextInactive  int32
    DarkModeBorder             int32
    DarkModeBorderInactive     int32
    LightModeTitleBar          int32
    LightModeTitleBarInactive  int32
    LightModeTitleText         int32
    LightModeTitleTextInactive int32
    LightModeBorder            int32
    LightModeBorderInactive    int32
}

type WailsEvent

type WailsEvent struct {
    Name      string `json:"name"`
    Data      any    `json:"data"`
    Sender    string `json:"sender"`
    Cancelled bool
}

func \*WailsEvent Cancel

func (e *WailsEvent) Cancel()

type WebviewWindow

type WebviewWindow struct {
    // contains filtered or unexported fields
}

func \*WebviewWindow AbsolutePosition

func (w *WebviewWindow) AbsolutePosition() (int, int)

AbsolutePosition returns the absolute position of the window to the screen

func \*WebviewWindow Center

func (w *WebviewWindow) Center()

Center centers the window on the screen

func \*WebviewWindow Close

func (w *WebviewWindow) Close()

Close closes the window

func \*WebviewWindow Destroy

func (w *WebviewWindow) Destroy()

func \*WebviewWindow ExecJS

func (w *WebviewWindow) ExecJS(js string)

ExecJS executes the given javascript in the context of the window.

func \*WebviewWindow Flash

func (w *WebviewWindow) Flash(enabled bool)

Flash flashes the window's taskbar button/icon. Windows only.

func \*WebviewWindow Focus

func (w *WebviewWindow) Focus()

func \*WebviewWindow ForceReload

func (w *WebviewWindow) ForceReload()

ForceReload forces the window to reload the page assets

func \*WebviewWindow Fullscreen

func (w *WebviewWindow) Fullscreen() *WebviewWindow

Fullscreen sets the window to fullscreen mode. Min/Max size constraints are disabled.

func \*WebviewWindow GetScreen

func (w *WebviewWindow) GetScreen() (*Screen, error)

GetScreen returns the screen that the window is on

func \*WebviewWindow GetZoom

func (w *WebviewWindow) GetZoom() float64

GetZoom returns the current zoom level of the window.

func \*WebviewWindow Height

func (w *WebviewWindow) Height() int

Height returns the height of the window

func \*WebviewWindow Hide

func (w *WebviewWindow) Hide() *WebviewWindow

Hide hides the window.

func \*WebviewWindow IsFocused

func (w *WebviewWindow) IsFocused() bool

IsFocused returns true if the window is currently focused

func \*WebviewWindow IsFullscreen

func (w *WebviewWindow) IsFullscreen() bool

IsFullscreen returns true if the window is fullscreen

func \*WebviewWindow IsMaximised

func (w *WebviewWindow) IsMaximised() bool

IsMaximised returns true if the window is maximised

func \*WebviewWindow IsMinimised

func (w *WebviewWindow) IsMinimised() bool

IsMinimised returns true if the window is minimised

func \*WebviewWindow IsVisible

func (w *WebviewWindow) IsVisible() bool

IsVisible returns true if the window is visible

func \*WebviewWindow Maximise

func (w *WebviewWindow) Maximise() *WebviewWindow

Maximise maximises the window. Min/Max size constraints are disabled.

func \*WebviewWindow Minimise

func (w *WebviewWindow) Minimise() *WebviewWindow

Minimise minimises the window.

func \*WebviewWindow Name

func (w *WebviewWindow) Name() string

Name returns the name of the window

func \*WebviewWindow NativeWindowHandle

func (w *WebviewWindow) NativeWindowHandle() (uintptr, error)

NativeWindowHandle returns the platform native window handle for the window.

func \*WebviewWindow On

func (w *WebviewWindow) On(eventType events.WindowEventType, callback func(event *WindowEvent)) func()

On registers a callback for the given window event

func \*WebviewWindow Print

func (w *WebviewWindow) Print() error

func \*WebviewWindow RegisterContextMenu

func (w *WebviewWindow) RegisterContextMenu(name string, menu *Menu)

RegisterContextMenu registers a context menu and assigns it the given name.

func \*WebviewWindow RegisterHook

func (w *WebviewWindow) RegisterHook(eventType events.WindowEventType, callback func(event *WindowEvent)) func()

RegisterHook registers a hook for the given window event

func \*WebviewWindow RelativePosition

func (w *WebviewWindow) RelativePosition() (int, int)

RelativePosition returns the relative position of the window to the screen

func \*WebviewWindow Reload

func (w *WebviewWindow) Reload()

Reload reloads the page assets

func \*WebviewWindow Resizable

func (w *WebviewWindow) Resizable() bool

Resizable returns true if the window is resizable.

func \*WebviewWindow Restore

func (w *WebviewWindow) Restore()

Restore restores the window to its previous state if it was previously minimised, maximised or fullscreen.

func \*WebviewWindow SetAbsolutePosition

func (w *WebviewWindow) SetAbsolutePosition(x int, y int)

func \*WebviewWindow SetAlwaysOnTop

func (w *WebviewWindow) SetAlwaysOnTop(b bool) *WebviewWindow

SetAlwaysOnTop sets the window to be always on top.

func \*WebviewWindow SetBackgroundColour

func (w *WebviewWindow) SetBackgroundColour(colour RGBA) *WebviewWindow

SetBackgroundColour sets the background colour of the window

func \*WebviewWindow SetEnabled

func (w *WebviewWindow) SetEnabled(enabled bool)

func \*WebviewWindow SetFrameless

func (w *WebviewWindow) SetFrameless(frameless bool) *WebviewWindow

SetFrameless removes the window frame and title bar

func \*WebviewWindow SetFullscreenButtonEnabled

func (w *WebviewWindow) SetFullscreenButtonEnabled(enabled bool) *WebviewWindow

func \*WebviewWindow SetHTML

func (w *WebviewWindow) SetHTML(html string) *WebviewWindow

SetHTML sets the HTML of the window to the given html string.

func \*WebviewWindow SetMaxSize

func (w *WebviewWindow) SetMaxSize(maxWidth, maxHeight int) *WebviewWindow

SetMaxSize sets the maximum size of the window.

func \*WebviewWindow SetMinSize

func (w *WebviewWindow) SetMinSize(minWidth, minHeight int) *WebviewWindow

SetMinSize sets the minimum size of the window.

func \*WebviewWindow SetRelativePosition

func (w *WebviewWindow) SetRelativePosition(x, y int) *WebviewWindow

SetRelativePosition sets the position of the window.

func \*WebviewWindow SetResizable

func (w *WebviewWindow) SetResizable(b bool) *WebviewWindow

SetResizable sets whether the window is resizable.

func \*WebviewWindow SetSize

func (w *WebviewWindow) SetSize(width, height int) *WebviewWindow

SetSize sets the size of the window

func \*WebviewWindow SetTitle

func (w *WebviewWindow) SetTitle(title string) *WebviewWindow

SetTitle sets the title of the window

func \*WebviewWindow SetURL

func (w *WebviewWindow) SetURL(s string) *WebviewWindow

func \*WebviewWindow SetZoom

func (w *WebviewWindow) SetZoom(magnification float64) *WebviewWindow

SetZoom sets the zoom level of the window.

func \*WebviewWindow Show

func (w *WebviewWindow) Show() *WebviewWindow

Show shows the window.

func \*WebviewWindow Size

func (w *WebviewWindow) Size() (int, int)

Size returns the size of the window

func \*WebviewWindow ToggleDevTools

func (w *WebviewWindow) ToggleDevTools()

func \*WebviewWindow ToggleFullscreen

func (w *WebviewWindow) ToggleFullscreen()

ToggleFullscreen toggles the window between fullscreen and normal

func \*WebviewWindow ToggleMaximise

func (w *WebviewWindow) ToggleMaximise()

ToggleMaximise toggles the window between maximised and normal

func \*WebviewWindow UnFullscreen

func (w *WebviewWindow) UnFullscreen()

UnFullscreen un-fullscreens the window.

func \*WebviewWindow UnMaximise

func (w *WebviewWindow) UnMaximise()

UnMaximise un-maximises the window.

func \*WebviewWindow UnMinimise

func (w *WebviewWindow) UnMinimise()

UnMinimise un-minimises the window. Min/Max size constraints are re-enabled.

func \*WebviewWindow Width

func (w *WebviewWindow) Width() int

Width returns the width of the window

func \*WebviewWindow Zoom

func (w *WebviewWindow) Zoom()

func \*WebviewWindow ZoomIn

func (w *WebviewWindow) ZoomIn()

ZoomIn increases the zoom level of the webview content

func \*WebviewWindow ZoomOut

func (w *WebviewWindow) ZoomOut()

ZoomOut decreases the zoom level of the webview content

func \*WebviewWindow ZoomReset

func (w *WebviewWindow) ZoomReset() *WebviewWindow

ZoomReset resets the zoom level of the webview content to 100%

type WebviewWindowOptions

type WebviewWindowOptions struct {
    // Name is a unique identifier that can be given to a window.
    Name string

    // Title is the title of the window.
    Title string

    // Width is the starting width of the window.
    Width int

    // Height is the starting height of the window.
    Height int

    // AlwaysOnTop will make the window float above other windows.
    AlwaysOnTop bool

    // URL is the URL to load in the window.
    URL string

    // DisableResize will disable the ability to resize the window.
    DisableResize bool

    // Frameless will remove the window frame.
    Frameless bool

    // MinWidth is the minimum width of the window.
    MinWidth int

    // MinHeight is the minimum height of the window.
    MinHeight int

    // MaxWidth is the maximum width of the window.
    MaxWidth int

    // MaxHeight is the maximum height of the window.
    MaxHeight int

    // StartState indicates the state of the window when it is first shown.
    // Default: WindowStateNormal
    StartState WindowState

    // Centered will center the window on the screen.
    Centered bool

    // BackgroundType is the type of background to use for the window.
    // Default: BackgroundTypeSolid
    BackgroundType BackgroundType

    // BackgroundColour is the colour to use for the window background.
    BackgroundColour RGBA

    // HTML is the HTML to load in the window.
    HTML string

    // JS is the JavaScript to load in the window.
    JS  string

    // CSS is the CSS to load in the window.
    CSS string

    // X is the starting X position of the window.
    X   int

    // Y is the starting Y position of the window.
    Y   int

    // TransparentTitlebar will make the titlebar transparent.
    // TODO: Move to mac window options
    FullscreenButtonEnabled bool

    // Hidden will hide the window when it is first created.
    Hidden bool

    // Zoom is the zoom level of the window.
    Zoom float64

    // ZoomControlEnabled will enable the zoom control.
    ZoomControlEnabled bool

    // EnableDragAndDrop will enable drag and drop.
    EnableDragAndDrop bool

    // OpenInspectorOnStartup will open the inspector when the window is first shown.
    OpenInspectorOnStartup bool

    // Mac options
    Mac MacWindow

    // Windows options
    Windows WindowsWindow

    // Focused indicates the window should be focused when initially shown
    Focused bool

    // ShouldClose is called when the window is about to close.
    // Return true to allow the window to close, or false to prevent it from closing.
    ShouldClose func(window *WebviewWindow) bool

    // If true, the window's devtools will be available (default true in builds without the `production` build tag)
    DevToolsEnabled bool

    // If true, the window's default context menu will be disabled (default false)
    DefaultContextMenuDisabled bool

    // KeyBindings is a map of key bindings to functions
    KeyBindings map[string]func(window *WebviewWindow)
}

type Win32Menu

type Win32Menu struct {
    // contains filtered or unexported fields
}

func NewApplicationMenu

func NewApplicationMenu(parent w32.HWND, inputMenu *Menu) *Win32Menu

func NewPopupMenu

func NewPopupMenu(parent w32.HWND, inputMenu *Menu) *Win32Menu

func \*Win32Menu Destroy

func (p *Win32Menu) Destroy()

func \*Win32Menu OnMenuClose

func (p *Win32Menu) OnMenuClose(fn func())

func \*Win32Menu OnMenuOpen

func (p *Win32Menu) OnMenuOpen(fn func())

func \*Win32Menu ProcessCommand

func (p *Win32Menu) ProcessCommand(cmdMsgID int) bool

func \*Win32Menu ShowAt

func (p *Win32Menu) ShowAt(x int, y int)

func \*Win32Menu ShowAtCursor

func (p *Win32Menu) ShowAtCursor()

func \*Win32Menu Update

func (p *Win32Menu) Update()

func \*Win32Menu UpdateMenuItem

func (p *Win32Menu) UpdateMenuItem(item *MenuItem)

type WindowAttachConfig

type WindowAttachConfig struct {
    // Window is the window to attach to the system tray. If it's null, the request to attach will be ignored.
    Window *WebviewWindow

    // Offset indicates the gap in pixels between the system tray and the window
    Offset int

    // Debounce is used by Windows to indicate how long to wait before responding to a mouse
    // up event on the notification icon. See https://stackoverflow.com/questions/4585283/alternate-showing-hiding-window-when-notify-icon-is-clicked
    Debounce time.Duration
    // contains filtered or unexported fields
}

type WindowEvent

type WindowEvent struct {
    Cancelled bool
    // contains filtered or unexported fields
}

func NewWindowEvent

func NewWindowEvent() *WindowEvent

func \*WindowEvent Cancel

func (w *WindowEvent) Cancel()

func \*WindowEvent Context

func (w *WindowEvent) Context() *WindowEventContext

type WindowEventContext

type WindowEventContext struct {
    // contains filtered or unexported fields
}

func WindowEventContext DroppedFiles

func (c WindowEventContext) DroppedFiles() []string

type WindowEventListener

type WindowEventListener struct {
    // contains filtered or unexported fields
}

type WindowState

type WindowState int

const (
    WindowStateNormal WindowState = iota
    WindowStateMinimised
    WindowStateMaximised
    WindowStateFullscreen
)

type WindowsOptions

WindowsOptions contains options for Windows applications.

type WindowsOptions struct {

    // WndProcInterceptor is a function that will be called for every message sent in the application.
    // Use this to hook into the main message loop. This is useful for handling custom window messages.
    // If `shouldReturn` is `true` then `returnCode` will be returned by the main message loop.
    // If `shouldReturn` is `false` then returnCode will be ignored and the message will be processed by the main message loop.
    WndProcInterceptor func(hwnd uintptr, msg uint32, wParam, lParam uintptr) (returnCode uintptr, shouldReturn bool)

    // DisableQuitOnLastWindowClosed disables the auto quit of the application if the last window has been closed.
    DisableQuitOnLastWindowClosed bool

    // Path where the WebView2 stores the user data. If empty %APPDATA%\[BinaryName.exe] will be used.
    // If the path is not valid, a messagebox will be displayed with the error and the app will exit with error code.
    WebviewUserDataPath string

    // Path to the directory with WebView2 executables. If empty WebView2 installed in the system will be used.
    WebviewBrowserPath string
}

type WindowsWindow

type WindowsWindow struct {
    // Select the type of translucent backdrop. Requires Windows 11 22621 or later.
    // Only used when window's `BackgroundType` is set to `BackgroundTypeTranslucent`.
    // Default: Auto
    BackdropType BackdropType

    // Disable the icon in the titlebar
    // Default: false
    DisableIcon bool

    // Theme (Dark / Light / SystemDefault)
    // Default: SystemDefault - The application will follow system theme changes.
    Theme Theme

    // Specify custom colours to use for dark/light mode
    // Default: nil
    CustomTheme *ThemeSettings

    // Disable all window decorations in Frameless mode, which means no "Aero Shadow" and no "Rounded Corner" will be shown.
    // "Rounded Corners" are only available on Windows 11.
    // Default: false
    DisableFramelessWindowDecorations bool

    // WindowMask is used to set the window shape. Use a PNG with an alpha channel to create a custom shape.
    // Default: nil
    WindowMask []byte

    // WindowMaskDraggable is used to make the window draggable by clicking on the window mask.
    // Default: false
    WindowMaskDraggable bool

    // WebviewGpuIsDisabled is used to enable / disable GPU acceleration for the webview
    // Default: false
    WebviewGpuIsDisabled bool

    // ResizeDebounceMS is the amount of time to debounce redraws of webview2
    // when resizing the window
    // Default: 0
    ResizeDebounceMS uint16

    // Disable the menu bar for this window
    // Default: false
    DisableMenu bool

    // Event mapping for the window. This allows you to define a translation from one event to another.
    // Default: nil
    EventMapping map[events.WindowEventType]events.WindowEventType

    // HiddenOnTaskbar hides the window from the taskbar
    // Default: false
    HiddenOnTaskbar bool

    // EnableSwipeGestures enables swipe gestures for the window
    // Default: false
    EnableSwipeGestures bool

    // EnableFraudulentWebsiteWarnings will enable warnings for fraudulent websites.
    // Default: false
    EnableFraudulentWebsiteWarnings bool

    // Menu is the menu to use for the window.
    Menu *Menu
}