Documentation
¶
Overview ¶
Package shortcut provides keyboard shortcut management for guigui/ebiten application.
Register every action with Set. The chord on the action is the default. A Store holds the user's replacements: a missing id keeps the default, and the value Unbound clears the chord. Dispatch runs the first matching action. If two actions still share a chord, the earlier one wins.
Index ¶
- Constants
- func Assign(store Store, id string, chord Chord)
- func Dispatch(store Store) bool
- func Display(store Store, id string) string
- func Reset(store Store, id string)
- func Set(actions []Action)
- func Unbind(store Store, id string)
- type Action
- type Chord
- type Editor
- func (e *Editor) Bind(v any)
- func (e *Editor) Build(context *guigui.Context, adder *guigui.ChildAdder) error
- func (e *Editor) Layout(context *guigui.Context, widgetBounds *guigui.WidgetBounds, ...)
- func (e *Editor) Measure(context *guigui.Context, constraints guigui.Constraints) image.Point
- func (e *Editor) WriteStateKey(context *guigui.Context, w *guigui.StateKeyWriter)
- type Store
Constants ¶
const Unbound = "-"
Unbound is the stored chord text that means "this action has no key".
Variables ¶
This section is empty.
Functions ¶
func Assign ¶
Assign stores chord for id. Another action that already uses chord becomes unbound. A chord equal to the action default removes the override.
func Dispatch ¶
Dispatch runs the first action whose chord was just pressed. It returns true when an action ran.
func Display ¶
Display is the chord text shown for id. A cleared action is "Not set". Text that does not parse is shown unchanged.
func Reset ¶
Reset gives id its default chord again. If another action uses that chord, Reset takes it back.
Types ¶
type Chord ¶
type Chord struct {
Key ebiten.Key
Ctrl bool
Alt bool
Shift bool
Meta bool
// contains filtered or unexported fields
}
Chord is one key plus the modifiers that must be held with it. The zero Chord is not a binding. ebiten.KeyA is numeric zero, so a missing valid flag is what marks an empty chord.
func FromPress ¶
FromPress builds a chord from a key and the modifiers held with it. Modifier keys themselves are not chords.
type Editor ¶
type Editor struct {
guigui.DefaultWidget
// contains filtered or unexported fields
}
Editor is a widget for the management of keyboard shortcuts. It lists registered shortcut actions and allows the user to capture new chords.
func (*Editor) Layout ¶
func (e *Editor) Layout(context *guigui.Context, widgetBounds *guigui.WidgetBounds, layouter *guigui.ChildLayouter)
func (*Editor) WriteStateKey ¶
func (e *Editor) WriteStateKey(context *guigui.Context, w *guigui.StateKeyWriter)