runtime

package
v2.12.0 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2026 License: MIT Imports: 11 Imported by: 363

Documentation

Index

Constants

View Source
const (
	InfoDialog     = frontend.InfoDialog
	WarningDialog  = frontend.WarningDialog
	ErrorDialog    = frontend.ErrorDialog
	QuestionDialog = frontend.QuestionDialog
)

Variables

This section is empty.

Functions

func BrowserOpenURL

func BrowserOpenURL(ctx context.Context, url string)

BrowserOpenURL uses the system default browser to open the url

func CheckNotificationAuthorization added in v2.12.0

func CheckNotificationAuthorization(ctx context.Context) (bool, error)

CheckNotificationAuthorization checks the current notification authorization status. On macOS, this checks if the app has notification permissions. On other platforms, this always returns true.

func CleanupNotifications added in v2.12.0

func CleanupNotifications(ctx context.Context)

CleanupNotifications cleans up notification resources and releases any held connections. This should be called when shutting down the application to properly release resources (primarily needed on Linux to close D-Bus connections).

func ClipboardGetText added in v2.4.0

func ClipboardGetText(ctx context.Context) (string, error)

func ClipboardSetText added in v2.4.0

func ClipboardSetText(ctx context.Context, text string) error

func EventsEmit

func EventsEmit(ctx context.Context, eventName string, optionalData ...interface{})

EventsEmit pass through

func EventsOff

func EventsOff(ctx context.Context, eventName string, additionalEventNames ...string)

EventsOff unregisters a listener for the given event name, optionally multiple listeners can be unregistered via `additionalEventNames`

func EventsOffAll added in v2.2.0

func EventsOffAll(ctx context.Context)

EventsOff unregisters a listener for the given event name, optionally multiple listeners can be unregistered via `additionalEventNames`

func EventsOn

func EventsOn(ctx context.Context, eventName string, callback func(optionalData ...interface{})) func()

EventsOn registers a listener for the given event name. It returns a function to cancel the listener

func EventsOnMultiple

func EventsOnMultiple(ctx context.Context, eventName string, callback func(optionalData ...interface{}), counter int) func()

EventsOnMultiple registers a listener for the given event name, that may be called a maximum of 'counter' times. It returns a function to cancel the listener

func EventsOnce

func EventsOnce(ctx context.Context, eventName string, callback func(optionalData ...interface{})) func()

EventsOnce registers a listener for the given event name. After the first callback, the listener is deleted. It returns a function to cancel the listener

func Hide

func Hide(ctx context.Context)

Hide the application

func InitializeNotifications added in v2.12.0

func InitializeNotifications(ctx context.Context) error

InitializeNotifications initializes the notification service for the application. This must be called before sending any notifications. On macOS, this also ensures the notification delegate is properly initialized.

func IsNotificationAvailable added in v2.12.0

func IsNotificationAvailable(ctx context.Context) bool

IsNotificationAvailable checks if notifications are available on the current platform.

func LogDebug

func LogDebug(ctx context.Context, message string)

LogDebug prints a Debug level message

func LogDebugf

func LogDebugf(ctx context.Context, format string, args ...interface{})

LogDebugf prints a Debug level message

func LogError

func LogError(ctx context.Context, message string)

LogError prints a Error level message

func LogErrorf

func LogErrorf(ctx context.Context, format string, args ...interface{})

LogErrorf prints a Error level message

func LogFatal

func LogFatal(ctx context.Context, message string)

LogFatal prints a Fatal level message

func LogFatalf

func LogFatalf(ctx context.Context, format string, args ...interface{})

LogFatalf prints a Fatal level message

func LogInfo

func LogInfo(ctx context.Context, message string)

LogInfo prints a Info level message

func LogInfof

func LogInfof(ctx context.Context, format string, args ...interface{})

LogInfof prints a Info level message

func LogPrint

func LogPrint(ctx context.Context, message string)

LogPrint prints a Print level message

func LogPrintf

func LogPrintf(ctx context.Context, format string, args ...interface{})

LogPrintf prints a Print level message

func LogSetLogLevel

func LogSetLogLevel(ctx context.Context, level logger.LogLevel)

LogSetLogLevel sets the log level

func LogTrace

func LogTrace(ctx context.Context, message string)

LogTrace prints a Trace level message

func LogTracef

func LogTracef(ctx context.Context, format string, args ...interface{})

LogTracef prints a Trace level message

func LogWarning

func LogWarning(ctx context.Context, message string)

LogWarning prints a Warning level message

func LogWarningf

func LogWarningf(ctx context.Context, format string, args ...interface{})

LogWarningf prints a Warning level message

func MenuSetApplicationMenu(ctx context.Context, menu *menu.Menu)
func MenuUpdateApplicationMenu(ctx context.Context)

func MessageDialog

func MessageDialog(ctx context.Context, dialogOptions MessageDialogOptions) (string, error)

MessageDialog show a message dialog to the user

func OnFileDrop added in v2.9.0

func OnFileDrop(ctx context.Context, callback func(x, y int, paths []string))

OnFileDrop returns a slice of file path strings when a drop is finished.

func OnFileDropOff added in v2.9.0

func OnFileDropOff(ctx context.Context)

OnFileDropOff removes the drag and drop listeners and handlers.

func OnNotificationResponse added in v2.12.0

func OnNotificationResponse(ctx context.Context, callback func(result NotificationResult))

OnNotificationResponse registers a callback function that will be invoked when a user interacts with a notification (e.g., clicks an action button or the notification itself). The callback receives a NotificationResult containing the response details or any errors.

func OpenDirectoryDialog

func OpenDirectoryDialog(ctx context.Context, dialogOptions OpenDialogOptions) (string, error)

OpenDirectoryDialog prompts the user to select a directory

func OpenFileDialog

func OpenFileDialog(ctx context.Context, dialogOptions OpenDialogOptions) (string, error)

OpenFileDialog prompts the user to select a file

func OpenMultipleFilesDialog

func OpenMultipleFilesDialog(ctx context.Context, dialogOptions OpenDialogOptions) ([]string, error)

OpenMultipleFilesDialog prompts the user to select a file

func Quit

func Quit(ctx context.Context)

Quit the application

func RegisterNotificationCategory added in v2.12.0

func RegisterNotificationCategory(ctx context.Context, category NotificationCategory) error

RegisterNotificationCategory registers a notification category that can be used with SendNotificationWithActions. Categories define the action buttons and optional reply fields that will appear on notifications.

func RemoveAllDeliveredNotifications added in v2.12.0

func RemoveAllDeliveredNotifications(ctx context.Context) error

RemoveAllDeliveredNotifications removes all delivered notifications from the notification center. On Windows, this is a no-op as the platform manages notification lifecycle automatically.

func RemoveAllPendingNotifications added in v2.12.0

func RemoveAllPendingNotifications(ctx context.Context) error

RemoveAllPendingNotifications removes all pending notifications from the notification center. On Windows, this is a no-op as the platform manages notification lifecycle automatically.

func RemoveDeliveredNotification added in v2.12.0

func RemoveDeliveredNotification(ctx context.Context, identifier string) error

RemoveDeliveredNotification removes a specific delivered notification by its identifier. On Windows, this is a no-op as the platform manages notification lifecycle automatically.

func RemoveNotification added in v2.12.0

func RemoveNotification(ctx context.Context, identifier string) error

RemoveNotification removes a notification by its identifier. This is a convenience function that works across platforms. On macOS, use the more specific RemovePendingNotification or RemoveDeliveredNotification functions.

func RemoveNotificationCategory added in v2.12.0

func RemoveNotificationCategory(ctx context.Context, categoryId string) error

RemoveNotificationCategory removes a previously registered notification category.

func RemovePendingNotification added in v2.12.0

func RemovePendingNotification(ctx context.Context, identifier string) error

RemovePendingNotification removes a specific pending notification by its identifier. On Windows, this is a no-op as the platform manages notification lifecycle automatically.

func RequestNotificationAuthorization added in v2.12.0

func RequestNotificationAuthorization(ctx context.Context) (bool, error)

RequestNotificationAuthorization requests notification authorization from the user. On macOS, this prompts the user to allow notifications. On other platforms, this always returns true. Returns true if authorization was granted, false otherwise.

func ResetSignalHandlers added in v2.12.0

func ResetSignalHandlers()

ResetSignalHandlers resets signal handlers to allow panic recovery.

On Linux, WebKit (used for the webview) may install signal handlers without the SA_ONSTACK flag, which prevents Go from properly recovering from panics caused by nil pointer dereferences or other memory access violations.

Call this function immediately before code that might panic to ensure the signal handlers are properly configured for Go's panic recovery mechanism.

Example usage:

go func() {
    defer func() {
        if err := recover(); err != nil {
            log.Printf("Recovered from panic: %v", err)
        }
    }()
    runtime.ResetSignalHandlers()
    // Code that might panic...
}()

Note: This function only has an effect on Linux. On other platforms, it is a no-op.

func SaveFileDialog

func SaveFileDialog(ctx context.Context, dialogOptions SaveDialogOptions) (string, error)

SaveFileDialog prompts the user to select a file

func SendNotification added in v2.12.0

func SendNotification(ctx context.Context, options NotificationOptions) error

SendNotification sends a basic notification with the given options. The notification will display with the provided title, subtitle (if supported), and body text.

func SendNotificationWithActions added in v2.12.0

func SendNotificationWithActions(ctx context.Context, options NotificationOptions) error

SendNotificationWithActions sends a notification with action buttons. A NotificationCategory must be registered first using RegisterNotificationCategory. The options.CategoryID must match a previously registered category ID. If the category is not found, a basic notification will be sent instead.

func Show

func Show(ctx context.Context)

Show the application if it is hidden

func WindowCenter

func WindowCenter(ctx context.Context)

WindowCenter the window on the current screen

func WindowExecJS added in v2.1.0

func WindowExecJS(ctx context.Context, js string)

WindowExecJS executes the given Js in the window

func WindowFullscreen

func WindowFullscreen(ctx context.Context)

WindowFullscreen makes the window fullscreen

func WindowGetPosition

func WindowGetPosition(ctx context.Context) (int, int)

func WindowGetSize

func WindowGetSize(ctx context.Context) (int, int)

func WindowHide

func WindowHide(ctx context.Context)

WindowHide the window

func WindowIsFullscreen

func WindowIsFullscreen(ctx context.Context) bool

WindowIsFullscreen get the window state is window Fullscreen

func WindowIsMaximised

func WindowIsMaximised(ctx context.Context) bool

WindowIsMaximised get the window state is window Maximised

func WindowIsMinimised

func WindowIsMinimised(ctx context.Context) bool

WindowIsMinimised get the window state is window Minimised

func WindowIsNormal

func WindowIsNormal(ctx context.Context) bool

WindowIsNormal get the window state is window Normal

func WindowMaximise

func WindowMaximise(ctx context.Context)

WindowMaximise the window

func WindowMinimise

func WindowMinimise(ctx context.Context)

WindowMinimise the window

func WindowPrint added in v2.6.0

func WindowPrint(ctx context.Context)

func WindowReload

func WindowReload(ctx context.Context)

WindowReload will reload the window contents

func WindowReloadApp

func WindowReloadApp(ctx context.Context)

WindowReloadApp will reload the application

func WindowSetAlwaysOnTop

func WindowSetAlwaysOnTop(ctx context.Context, b bool)

WindowSetAlwaysOnTop sets the window AlwaysOnTop or not on top

func WindowSetBackgroundColour

func WindowSetBackgroundColour(ctx context.Context, R, G, B, A uint8)

func WindowSetDarkTheme

func WindowSetDarkTheme(ctx context.Context)

func WindowSetLightTheme

func WindowSetLightTheme(ctx context.Context)

func WindowSetMaxSize

func WindowSetMaxSize(ctx context.Context, width int, height int)

WindowSetMaxSize sets the maximum size of the window

func WindowSetMinSize

func WindowSetMinSize(ctx context.Context, width int, height int)

WindowSetMinSize sets the minimum size of the window

func WindowSetPosition

func WindowSetPosition(ctx context.Context, x int, y int)

WindowSetPosition sets the position of the window

func WindowSetSize

func WindowSetSize(ctx context.Context, width int, height int)

WindowSetSize sets the size of the window

func WindowSetSystemDefaultTheme

func WindowSetSystemDefaultTheme(ctx context.Context)

func WindowSetTitle

func WindowSetTitle(ctx context.Context, title string)

WindowSetTitle sets the title of the window

func WindowShow

func WindowShow(ctx context.Context)

WindowShow shows the window if hidden

func WindowToggleMaximise

func WindowToggleMaximise(ctx context.Context)

WindowToggleMaximise the window

func WindowUnfullscreen

func WindowUnfullscreen(ctx context.Context)

WindowUnfullscreen makes the window UnFullscreen

func WindowUnmaximise

func WindowUnmaximise(ctx context.Context)

WindowUnmaximise the window

func WindowUnminimise

func WindowUnminimise(ctx context.Context)

WindowUnminimise the window

Types

type DialogType

type DialogType = frontend.DialogType

type EnvironmentInfo

type EnvironmentInfo struct {
	BuildType string `json:"buildType"`
	Platform  string `json:"platform"`
	Arch      string `json:"arch"`
}

EnvironmentInfo contains information about the environment

func Environment

func Environment(ctx context.Context) EnvironmentInfo

Environment returns information about the environment

type FileFilter

type FileFilter = frontend.FileFilter

FileFilter defines a filter for dialog boxes

type MessageDialogOptions

type MessageDialogOptions = frontend.MessageDialogOptions

MessageDialogOptions contains the options for the Message dialogs, EG Info, Warning, etc runtime methods

type NotificationAction added in v2.12.0

type NotificationAction = frontend.NotificationAction

NotificationAction represents an action button for a notification.

type NotificationCategory added in v2.12.0

type NotificationCategory = frontend.NotificationCategory

NotificationCategory groups actions for notifications.

type NotificationOptions added in v2.12.0

type NotificationOptions = frontend.NotificationOptions

NotificationOptions contains configuration for a notification.

type NotificationResponse added in v2.12.0

type NotificationResponse = frontend.NotificationResponse

NotificationResponse represents the response sent by interacting with a notification.

type NotificationResult added in v2.12.0

type NotificationResult = frontend.NotificationResult

NotificationResult represents the result of a notification response, returning the response or any errors that occurred.

type OpenDialogOptions

type OpenDialogOptions = frontend.OpenDialogOptions

OpenDialogOptions contains the options for the OpenDialogOptions runtime method

type SaveDialogOptions

type SaveDialogOptions = frontend.SaveDialogOptions

SaveDialogOptions contains the options for the SaveDialog runtime method

type Screen

type Screen = frontend.Screen

func ScreenGetAll

func ScreenGetAll(ctx context.Context) ([]Screen, error)

ScreenGetAll returns all screens

Jump to

Keyboard shortcuts

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