keybinding

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2026 License: EUPL-1.2 Imports: 4 Imported by: 0

Documentation

Overview

pkg/keybinding/platform.go

pkg/keybinding/service.go

Index

Constants

This section is empty.

Variables

View Source
var ErrorAlreadyRegistered = core.E("keybinding", "accelerator already registered", nil)
View Source
var ErrorNotRegistered = core.E("keybinding", "accelerator not registered", nil)

Functions

func Register

func Register(p Platform) func(*core.Core) core.Result

Register(p) binds the keybinding service to a Core instance. core.WithService(keybinding.Register(wailsKeybinding))

Types

type ActionTriggered

type ActionTriggered struct {
	Accelerator string `json:"accelerator"`
}

ActionTriggered is broadcast when a registered key binding fires.

type BindingInfo

type BindingInfo struct {
	Accelerator string `json:"accelerator"`
	Description string `json:"description"`
}

BindingInfo describes a registered global key binding.

type Options

type Options struct{}

type Platform

type Platform interface {
	// Add registers a global keyboard shortcut with the given accelerator string.
	// The handler is called when the shortcut is triggered.
	// Accelerator syntax is platform-aware: "Cmd+S" (macOS), "Ctrl+S" (Windows/Linux).
	// Special keys: F1-F12, Escape, Enter, Space, Tab, Backspace, Delete, arrow keys.
	Add(accelerator string, handler func()) error

	// Remove unregisters a previously registered keyboard shortcut.
	Remove(accelerator string) error

	// Process triggers the registered handler for the given accelerator programmatically.
	// Returns true if a handler was found and invoked, false if not registered.
	//
	//	handled := platform.Process("Ctrl+S")
	Process(accelerator string) bool

	// GetAll returns all currently registered accelerator strings.
	// Used for adapter-level reconciliation only — not read by QueryList.
	GetAll() []string
}

Platform abstracts the keyboard shortcut backend (Wails v3).

type QueryList

type QueryList struct{}

QueryList returns all registered key bindings. Result: []BindingInfo

type Service

type Service struct {
	*core.ServiceRuntime[Options]
	// contains filtered or unexported fields
}

func (*Service) HandleIPCEvents

func (s *Service) HandleIPCEvents(_ *core.Core, _ core.Message) core.Result

func (*Service) OnStartup

func (s *Service) OnStartup(_ context.Context) core.Result

type TaskAdd

type TaskAdd struct {
	Accelerator string `json:"accelerator"`
	Description string `json:"description"`
}

TaskAdd registers a global key binding. Error: ErrorAlreadyRegistered if accelerator taken.

type TaskProcess

type TaskProcess struct {
	Accelerator string `json:"accelerator"`
}

TaskProcess triggers a registered key binding programmatically. Returns ActionTriggered if the accelerator was handled, ErrorNotRegistered if not found.

c.PERFORM(keybinding.TaskProcess{Accelerator: "Ctrl+S"})

type TaskRemove

type TaskRemove struct {
	Accelerator string `json:"accelerator"`
}

TaskRemove unregisters a global key binding by accelerator. Error: ErrorNotRegistered if not found.

Jump to

Keyboard shortcuts

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