action

package
v0.0.0-...-955f326 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2020 License: MPL-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Cut removes the selection and places it on the clipboard.
	Cut = &CmdAction{
		ActionID:        ids.CutItemID,
		ActionTitle:     i18n.Text("Cut"),
		ActionHotKey:    keys.X,
		ActionModifiers: keys.OSMenuCmdModifier(),
	}
	// Copy the selection and place it on the clipboard.
	Copy = &CmdAction{
		ActionID:        ids.CopyItemID,
		ActionTitle:     i18n.Text("Copy"),
		ActionHotKey:    keys.C,
		ActionModifiers: keys.OSMenuCmdModifier(),
	}
	// Paste the contents of the clipboard, replacing the selection.
	Paste = &CmdAction{
		ActionID:        ids.PasteItemID,
		ActionTitle:     i18n.Text("Paste"),
		ActionHotKey:    keys.V,
		ActionModifiers: keys.OSMenuCmdModifier(),
	}
	// Delete the selection.
	Delete = &CmdAction{
		ActionID:     ids.DeleteItemID,
		ActionTitle:  i18n.Text("Delete"),
		ActionHotKey: keys.Backspace,
	}
	// SelectAll selects everything in the current focus.
	SelectAll = &CmdAction{
		ActionID:        ids.SelectAllItemID,
		ActionTitle:     i18n.Text("Select All"),
		ActionHotKey:    keys.A,
		ActionModifiers: keys.OSMenuCmdModifier(),
	}
)

Functions

This section is empty.

Types

type Action

type Action interface {
	// ID returns a unique ID for the action. This value should be suitable
	// for use as a menu item ID.
	ID() int
	// Title returns the text to display for this action. Typically used in a
	// menu item title or tooltip for a button.
	Title() string
	// HotKey is the key that will trigger the action. Returns nil if no hot
	// key is set.
	HotKey() *keys.Key
	// HotKeyModifiers returns the modifier keys that must be pressed for the
	// hot key to be recognized.
	HotKeyModifiers() keys.Modifiers
	// Enabled returns true if the action can be used. Care should be made to
	// keep this method fast to avoid slowing down the user interface.
	Enabled(source interface{}) bool
	// Execute the action. Will only be called if the action has been
	// triggered and Enabled() returns true.
	Execute(source interface{})
}

Action describes an action that can be performed.

type CmdAction

type CmdAction struct {
	ActionID        int
	ActionTitle     string
	ActionHotKey    *keys.Key
	ActionModifiers keys.Modifiers
}

CmdAction provides a standardized way to issue commands to focused UI elements.

func (*CmdAction) Enabled

func (a *CmdAction) Enabled(source interface{}) bool

Enabled implements action.Action.

func (*CmdAction) Execute

func (a *CmdAction) Execute(source interface{})

Execute implements action.Action.

func (*CmdAction) HotKey

func (a *CmdAction) HotKey() *keys.Key

HotKey implements action.Action.

func (*CmdAction) HotKeyModifiers

func (a *CmdAction) HotKeyModifiers() keys.Modifiers

HotKeyModifiers implements action.Action.

func (*CmdAction) ID

func (a *CmdAction) ID() int

ID implements action.Action.

func (*CmdAction) Title

func (a *CmdAction) Title() string

Title implements action.Action.

Jump to

Keyboard shortcuts

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