application

package
v3.0.0-alpha.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 1, 2024 License: MIT Imports: 47 Imported by: 2

Documentation

Overview

Portions of this code are derived from the project: - https://github.com/fyne-io/systray

Index

Constants

View Source
const (
	// CmdOrCtrlKey represents Command on Mac and Control on other platforms
	CmdOrCtrlKey modifier = 0 << iota
	// OptionOrAltKey represents Option on Mac and Alt on other platforms
	OptionOrAltKey modifier = 1 << iota
	// ShiftKey represents the shift key on all systems
	ShiftKey modifier = 2 << iota
	// SuperKey represents Command on Mac and the Windows key on the other platforms
	SuperKey modifier = 3 << iota
	// ControlKey represents the control key on all systems
	ControlKey modifier = 4 << iota
)
View Source
const (
	ApplicationHide = 0
	ApplicationShow = 1
	ApplicationQuit = 2
)
View Source
const (
	ClipboardSetText = 0
	ClipboardText    = 1
)
View Source
const (
	DialogInfo     = 0
	DialogWarning  = 1
	DialogError    = 2
	DialogQuestion = 3
	DialogOpenFile = 4
	DialogSaveFile = 5
)
View Source
const (
	ScreensGetAll     = 0
	ScreensGetPrimary = 1
	ScreensGetCurrent = 2
)
View Source
const (
	SystemIsDarkMode = 0
	Environment      = 1
)
View Source
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
)
View Source
const (
	NSImageNone = iota
	NSImageOnly
	NSImageLeft
	NSImageRight
	NSImageBelow
	NSImageAbove
	NSImageOverlaps
	NSImageLeading
	NSImageTrailing
)
View Source
const (
	BrowserOpenURL = 0
)
View Source
const (
	CallBinding = 0
)
View Source
const (
	ContextMenuOpen = 0
)
View Source
const (
	EventsEmit = 0
)

Variables

View Source
var AlphaAssets = AssetOptions{
	FS: alphaAssets,
}

AlphaAssets is the default assets for the alpha application

View Source
var BuildInfo *debug.BuildInfo

BuildInfo contains the build info for the application

View Source
var BuildSettings map[string]string

BuildSettings contains the build settings for the application

View Source
var Disabled = u.False

Disabled means the feature should be disabled

View Source
var Enabled = u.True

Enabled means the feature should be enabled

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

MacTitleBarDefault results in the default Mac MacTitleBar

View Source
var MacTitleBarHidden = MacTitleBar{
	AppearsTransparent:   true,
	Hide:                 false,
	HideTitle:            true,
	FullSizeContent:      true,
	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.

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

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

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

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

View Source
var VirtualKeyCodes = map[uint]string{}/* 146 elements not displayed */
View Source
var WebviewWindowDefaults = &WebviewWindowOptions{
	Title:  "",
	Width:  800,
	Height: 600,
	URL:    "",
	BackgroundColour: RGBA{
		Red:   255,
		Green: 255,
		Blue:  255,
		Alpha: 255,
	},
}

Functions

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 InvokeSyncWithResultAndOther

func InvokeSyncWithResultAndOther[T any, U any](fn func() (T, U)) (res T, other U)

func ToARGB

func ToARGB(img *image.RGBA) (int, int, []byte)

Types

type ActivationPolicy

type ActivationPolicy int

ActivationPolicy is the activation policy for the application.

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) AssetServerHandler

func (a *App) AssetServerHandler() func(rw http.ResponseWriter, req *http.Request)

func (*App) BrowserOpenFile

func (a *App) BrowserOpenFile(path string) error

func (*App) BrowserOpenURL

func (a *App) BrowserOpenURL(url string) error

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) Environment

func (a *App) Environment() EnvironmentInfo

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) Window

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) OnShutdown

func (a *App) OnShutdown(f func())

OnShutdown adds a function to be run when the application is shutting down.

func (*App) OnWindowCreation

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

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) RegisterWindow

func (a *App) RegisterWindow(window Window) uint

func (*App) Run

func (a *App) Run() error

func (*App) SetIcon

func (a *App) SetIcon(icon []byte)

func (*App) SetMenu

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

func (*App) Show

func (a *App) Show()

func (*App) ShowAboutDialog

func (a *App) ShowAboutDialog()

func (*App) UnregisterWindow

func (a *App) UnregisterWindow(id uint)

type ApplicationEventContext

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

func (ApplicationEventContext) HasVisibleWindows

func (c ApplicationEventContext) HasVisibleWindows() bool

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

type AssetOptions struct {
	// FS defines the static assets to be used. A GET request is first tried to be served from this FS. If the FS returns
	// `os.ErrNotExist` for that file, the request handling will fallback to the Handler and tries to serve the GET
	// request from it.
	//
	// If set to nil, all GET requests will be forwarded to Handler.
	FS fs.FS

	// Handler will be called for every GET request that can't be served from FS, due to `os.ErrNotExist`. Furthermore all
	// non GET requests will always be served from this Handler.
	//
	// If not defined, the result is the following in cases where the Handler would have been called:
	//   GET request:   `http.StatusNotFound`
	//   Other request: `http.StatusMethodNotAllowed`
	Handler http.Handler

	// Middleware is 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.
	//
	// If not defined, the default AssetServer request chain is executed.
	//
	// Multiple Middlewares can be chained together with:
	//   ChainMiddleware(middleware ...Middleware) Middleware
	Middleware Middleware

	// DisableLogging disables logging of the AssetServer. By default, the AssetServer logs every request.
	DisableLogging bool
}

AssetOptions defines the configuration of the AssetServer.

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

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
}

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

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 Callback

type Callback interface {
	CallError(callID string, result string)
	CallResponse(callID string, result string)
	DialogError(dialogID string, result string)
	DialogResponse(dialogID string, result string, isJSON bool)
}

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 CoreWebView2PermissionKind

type CoreWebView2PermissionKind uint32
const (
	CoreWebView2PermissionKindUnknownPermission CoreWebView2PermissionKind = iota
	CoreWebView2PermissionKindMicrophone
	CoreWebView2PermissionKindCamera
	CoreWebView2PermissionKindGeolocation
	CoreWebView2PermissionKindNotifications
	CoreWebView2PermissionKindOtherSensors
	CoreWebView2PermissionKindClipboardRead
)

type CoreWebView2PermissionState

type CoreWebView2PermissionState uint32
const (
	CoreWebView2PermissionStateDefault CoreWebView2PermissionState = iota
	CoreWebView2PermissionStateAllow
	CoreWebView2PermissionStateDeny
)

type DialogType

type DialogType int
const (
	InfoDialogType DialogType = iota
	QuestionDialogType
	WarningDialogType
	ErrorDialogType
	OpenDirectoryDialogType
)

type DragEffect

type DragEffect int32
const (
	// DragEffectNone is used to indicate that the drop target cannot accept the data.
	DragEffectNone DragEffect = 1
	// DragEffectCopy is used to indicate that the data is copied to the drop target.
	DragEffectCopy DragEffect = 2
	// DragEffectMove is used to indicate that the data is removed from the drag source.
	DragEffectMove DragEffect = 3
	// DragEffectLink is used to indicate that a link to the original data is established.
	DragEffectLink DragEffect = 4
)

type EnvironmentInfo

type EnvironmentInfo struct {
	OS    string
	Arch  string
	Debug bool
}

EnvironmentInfo represents information about the current environment.

Fields: - OS: the operating system that the program is running on. - Arch: the architecture of the operating system. - Debug: indicates whether debug mode is enabled.

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

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

EventProcessor handles custom events

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 GSList

type GSList C.GSList

type GSListPointer

type GSListPointer *GSList

type IconPosition

type IconPosition int

type LinuxWindow

type LinuxWindow struct {
	ShowApplicationMenu bool
}

LinuxWindow contains macOS specific options

type MacAppearanceType

type MacAppearanceType string

MacAppearanceType is a type of Appearance for Cocoa windows

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

type MacBackdrop int

MacBackdrop is the backdrop type for macOS

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

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
}

MacOptions contains options for macOS applications.

type MacTitleBar

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
	// ToolbarStyle is the style of toolbar to use
	ToolbarStyle MacToolbarStyle
}

MacTitleBar contains options for the Mac titlebar

type MacToolbarStyle

type MacToolbarStyle int

MacToolbarStyle is the style of toolbar for macOS

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 MacWebviewPreferences

type MacWebviewPreferences struct {
	// TabFocusesLinks will enable tabbing to links
	TabFocusesLinks u.Bool
	// TextInteractionEnabled will enable text interaction
	TextInteractionEnabled u.Bool
	// FullscreenEnabled will enable fullscreen
	FullscreenEnabled u.Bool
}

MacWebviewPreferences contains preferences for the Mac webview

type MacWindow

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

	// WebviewPreferences contains preferences for the webview
	WebviewPreferences MacWebviewPreferences
}

MacWindow contains macOS specific options for Webview Windows

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

func NewMenu

func NewMenu() *Menu
func (m *Menu) Add(label string) *MenuItem
func (m *Menu) AddCheckbox(label string, enabled bool) *MenuItem
func (m *Menu) AddRadio(label string, enabled bool) *MenuItem
func (m *Menu) AddRole(role Role) *Menu
func (m *Menu) AddSeparator()
func (m *Menu) AddSubmenu(s string) *Menu
func (m *Menu) SetLabel(label string)
func (m *Menu) Update()
type MenuItem struct {
	// contains filtered or unexported fields
}
func (m *MenuItem) Checked() bool
func (m *MenuItem) Enabled() bool
func (m *MenuItem) Hidden() bool
func (m *MenuItem) IsCheckbox() bool
func (m *MenuItem) IsRadio() bool
func (m *MenuItem) IsSeparator() bool
func (m *MenuItem) IsSubmenu() bool
func (m *MenuItem) Label() string
func (m *MenuItem) OnClick(f func(*Context)) *MenuItem
func (m *MenuItem) SetAccelerator(shortcut string) *MenuItem
func (m *MenuItem) SetBitmap(bitmap []byte) *MenuItem
func (m *MenuItem) SetChecked(checked bool) *MenuItem
func (m *MenuItem) SetEnabled(enabled bool) *MenuItem
func (m *MenuItem) SetHidden(hidden bool) *MenuItem
func (m *MenuItem) SetLabel(s string) *MenuItem
func (m *MenuItem) SetTooltip(s string) *MenuItem
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 Window) *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) HandleRuntimeCallWithIDs

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

func (*MessageProcessor) Info

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

func (*MessageProcessor) ServeHTTP

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

type Middleware

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

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.

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 Window) *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 (used in the default about box)
	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 called when a panic occurs
	PanicHandler func(any)

	// DisableDefaultSignalHandler disables the default signal handler
	DisableDefaultSignalHandler bool

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

	// OnShutdown is called when the application is about to terminate.
	// This is useful for cleanup tasks.
	// The shutdown process blocks until this function returns
	OnShutdown func()

	// ShouldQuit is a function that is called when the user tries to quit the application.
	// If the function returns true, the application will quit.
	// If the function returns false, the application will not quit.
	ShouldQuit func() bool
}

type PX

type PX struct {
	W, H int
	Pix  []byte
}

type Parameter

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

Parameter defines a Go method parameter

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
}

func NewRGB

func NewRGB(red, green, blue uint8) RGBA

func NewRGBA

func NewRGBA(red, green, blue, alpha uint8) RGBA

type Rect

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

type Role

type Role uint

Role is a type to identify menu roles

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
	ShowDevTools       Role = iota
	ResetZoom          Role = iota
	ZoomIn             Role = iota
	ZoomOut            Role = iota
	ToggleFullscreen   Role = iota

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

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

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 Window) *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) Run

func (s *SystemTray) Run()

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

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
}

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

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()

func (WailsEvent) ToJSON

func (e WailsEvent) ToJSON() string

type WebviewWindow

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

func NewWindow

func NewWindow(options WebviewWindowOptions) *WebviewWindow

NewWindow creates a new window with the given options

func (*WebviewWindow) AbsolutePosition

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

AbsolutePosition returns the absolute position of the window to the screen

func (*WebviewWindow) CallError

func (w *WebviewWindow) CallError(callID string, result string)

func (*WebviewWindow) CallResponse

func (w *WebviewWindow) CallResponse(callID string, result string)

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) DialogError

func (w *WebviewWindow) DialogError(dialogID string, result string)

func (*WebviewWindow) DialogResponse

func (w *WebviewWindow) DialogResponse(dialogID string, result string, isJSON bool)

func (*WebviewWindow) DisableSizeConstraints

func (w *WebviewWindow) DisableSizeConstraints()

func (*WebviewWindow) DispatchWailsEvent

func (w *WebviewWindow) DispatchWailsEvent(event *WailsEvent)

func (*WebviewWindow) EnableSizeConstraints

func (w *WebviewWindow) EnableSizeConstraints()

func (*WebviewWindow) Error

func (w *WebviewWindow) Error(message string, args ...any)

func (*WebviewWindow) ExecJS

func (w *WebviewWindow) ExecJS(_callID, 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. Useful to indicate that attention is required. 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() Window

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) HandleDragAndDropMessage

func (w *WebviewWindow) HandleDragAndDropMessage(filenames []string)

func (*WebviewWindow) HandleKeyEvent

func (w *WebviewWindow) HandleKeyEvent(acceleratorString string)

func (*WebviewWindow) HandleMessage

func (w *WebviewWindow) HandleMessage(message string)

func (*WebviewWindow) HandleWindowEvent

func (w *WebviewWindow) HandleWindowEvent(id uint)

func (*WebviewWindow) Height

func (w *WebviewWindow) Height() int

Height returns the height of the window

func (*WebviewWindow) Hide

func (w *WebviewWindow) Hide() Window

Hide hides the window.

func (*WebviewWindow) ID

func (w *WebviewWindow) ID() uint

func (*WebviewWindow) Info

func (w *WebviewWindow) Info(message string, args ...any)

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() Window

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

func (*WebviewWindow) Minimise

func (w *WebviewWindow) Minimise() Window

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) OpenContextMenu

func (w *WebviewWindow) OpenContextMenu(data *ContextMenuData)

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) Run

func (w *WebviewWindow) Run()

func (*WebviewWindow) SetAbsolutePosition

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

func (*WebviewWindow) SetAlwaysOnTop

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

SetAlwaysOnTop sets the window to be always on top.

func (*WebviewWindow) SetBackgroundColour

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

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) Window

SetFrameless removes the window frame and title bar

func (*WebviewWindow) SetFullscreenButtonEnabled

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

func (*WebviewWindow) SetHTML

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

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

func (*WebviewWindow) SetMaxSize

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

SetMaxSize sets the maximum size of the window.

func (*WebviewWindow) SetMinSize

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

SetMinSize sets the minimum size of the window.

func (*WebviewWindow) SetRelativePosition

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

SetRelativePosition sets the position of the window.

func (*WebviewWindow) SetResizable

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

SetResizable sets whether the window is resizable.

func (*WebviewWindow) SetSize

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

SetSize sets the size of the window

func (*WebviewWindow) SetTitle

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

SetTitle sets the title of the window

func (*WebviewWindow) SetURL

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

func (*WebviewWindow) SetZoom

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

SetZoom sets the zoom level of the window.

func (*WebviewWindow) Show

func (w *WebviewWindow) Show() Window

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) 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() Window

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

	// 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)

	// IgnoreMouseEvents will ignore mouse events in the window
	IgnoreMouseEvents bool
}

type Window

type Window interface {
	Callback
	AbsolutePosition() (int, int)
	Center()
	Close()
	Destroy()
	DisableSizeConstraints()
	DispatchWailsEvent(event *WailsEvent)
	EnableSizeConstraints()
	Error(message string, args ...any)
	ExecJS(callID, js string)
	Focus()
	ForceReload()
	Fullscreen() Window
	GetScreen() (*Screen, error)
	GetZoom() float64
	HandleDragAndDropMessage(filenames []string)
	HandleMessage(message string)
	HandleWindowEvent(id uint)
	Height() int
	Hide() Window
	ID() uint
	Info(message string, args ...any)
	IsFullscreen() bool
	IsMaximised() bool
	IsMinimised() bool
	HandleKeyEvent(acceleratorString string)
	Maximise() Window
	Minimise() Window
	Name() string
	On(eventType events.WindowEventType, callback func(event *WindowEvent)) func()
	OpenContextMenu(data *ContextMenuData)
	RegisterContextMenu(name string, menu *Menu)
	RelativePosition() (int, int)
	Reload()
	Resizable() bool
	Restore()
	Run()
	SetAbsolutePosition(x, y int)
	SetAlwaysOnTop(b bool) Window
	SetBackgroundColour(colour RGBA) Window
	SetFrameless(frameless bool) Window
	SetFullscreenButtonEnabled(enabled bool) Window
	SetHTML(html string) Window
	SetMaxSize(maxWidth, maxHeight int) Window
	SetMinSize(minWidth, minHeight int) Window
	SetRelativePosition(x, y int) Window
	SetResizable(b bool) Window
	SetSize(width, height int) Window
	SetTitle(title string) Window
	SetURL(s string) Window
	SetZoom(magnification float64) Window
	Show() Window
	Size() (width int, height int)
	ToggleDevTools()
	ToggleFullscreen()
	UnFullscreen()
	UnMaximise()
	UnMinimise()
	Width() int
	Zoom()
	ZoomIn()
	ZoomOut()
	ZoomReset() Window
}

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

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
}

WindowsOptions contains options for Windows applications.

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

	// Drag Cursor Effects
	OnEnterEffect DragEffect
	OnOverEffect  DragEffect

	// Permissions map for WebView2. If empty, default permissions will be granted.
	Permissions map[CoreWebView2PermissionKind]CoreWebView2PermissionState
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL