event

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2025 License: MIT Imports: 3 Imported by: 9

Documentation

Overview

Package event defines various types of GUI events

Index

Constants

View Source
const (
	GeneralType   int // GeneralType represents a general event type
	KeyboardType      // KeyboardType represents a keyboard event type
	ButtonType        // ButtonType represents a mouse button event type
	MotionType        // MotionType represents a mouse motion event type
	MenuType          // MenuType represents a menu action event type
	ConfigureType     // ConfigureType represents a window configuration event type
	ScrollType        // ScrollType represents a scroll event type
	ClipboardType     // ClipboardType represents a clipboard event type
)

Event types.

View Source
const (
	ButtonActionPress   = 4 // ButtonActionPress represents a button press action
	ButtonActionDouble  = 5 // ButtonActionDouble represents a double-click action
	ButtonActionTriple  = 6 // ButtonActionTriple represents a triple-click action
	ButtonActionRelease = 7 // ButtonActionRelease represents a button release action
)

Button action types.

View Source
const (
	ButtonLeft   = 1 // ButtonLeft represents the left mouse button
	ButtonMiddle = 2 // ButtonMiddle represents the middle mouse button
	ButtonRight  = 3 // ButtonRight represents the right mouse button
)

Button numbers.

View Source
const (
	ScrollUp     = 0 // ScrollUp represents scrolling up
	ScrollDown   = 1 // ScrollDown represents scrolling down
	ScrollLeft   = 2 // ScrollLeft represents scrolling left
	ScrollRight  = 3 // ScrollRight represents scrolling right
	ScrollSmooth = 4 // ScrollSmooth represents smooth scrolling
)

Scroll direction types.

Variables

View Source
var (
	UnknownEvent = General{Event: 0} // UnknownEvent represents an unknown event
	DestroyEvent = General{Event: 1} // DestroyEvent represents a destroy event
)

Predefined general events.

View Source
var (
	KeyLeft      = Keyboard{Name: "Left"}
	KeyRight     = Keyboard{Name: "Right"}
	KeyUp        = Keyboard{Name: "Up"}
	KeyDown      = Keyboard{Name: "Down"}
	KeyBackSpace = Keyboard{Rune: 8, Name: "BackSpace"}
	KeyTab       = Keyboard{Rune: 9, Name: "Tab"}
	KeyEnter     = Keyboard{Rune: 13, Name: "Return"}
	KeyEscape    = Keyboard{Rune: 27, Name: "Escape"}
	KeySpace     = Keyboard{Rune: 32, Name: "space"}
	KeyDelete    = Keyboard{Rune: 127, Name: "Delete"}
	KeyPageUp    = Keyboard{Name: "Page_Up"}
	KeyPageDown  = Keyboard{Name: "Page_Down"}
	KeyHome      = Keyboard{Name: "Home"}
	KeyEnd       = Keyboard{Name: "End"}
)

Predefined keyboard events.

View Source
var (
	KeySave  = Keyboard{Rune: 115, Name: "s", Control: true}
	KeyExit  = Keyboard{Rune: 119, Name: "w", Control: true}
	KeyCopy  = Keyboard{Rune: 99, Name: "c", Control: true}
	KeyPaste = Keyboard{Rune: 118, Name: "v", Control: true}
)

Platform specified keyboard events

Functions

This section is empty.

Types

type Button

type Button struct {
	Action int         // Action represents the button action type
	Button int         // Button represents the mouse button number
	Point  image.Point // Point represents the location of the mouse pointer
}

Button represents a mouse button event.

func (Button) Type

func (e Button) Type() int

Type returns the type of the button event.

type Clipboard added in v0.4.0

type Clipboard struct {
	Data clipboard.Clipboarder // Data represents the clipboard content
}

Clipboard represents an event with clipboard data.

func (Clipboard) Type added in v0.4.0

func (c Clipboard) Type() int

Type returns the type of the clipboard event.

type Configure

type Configure struct {
	Size      image.Point // Size represents the size of the window
	InnerSize image.Point // InnerSize represents the size of the inner part of the window
}

Configure represents a window configuration event.

func (Configure) Type

func (e Configure) Type() int

Type returns the type of the configure event.

type Eventer

type Eventer interface {
	Type() int // Type returns the type of GUI event
}

Eventer is the interface that groups GUI events.

type General

type General struct {
	Event int // Event identifies the specific general event
}

General represents a general-purpose notification event.

func (General) Type

func (e General) Type() int

Type returns the type of the general event.

type Keyboard

type Keyboard struct {
	Rune    rune   // Rune represents the character input from the keyboard
	Shift   bool   // Shift indicates if the Shift key is pressed
	Control bool   // Control indicates if the Control key is pressed
	Alt     bool   // Alt indicates if the Alt key is pressed
	Meta    bool   // Meta indicates if the Meta key is pressed
	Name    string // Name represents the name of the key
}

Keyboard represents a keyboard event.

func (Keyboard) IsGraphic

func (e Keyboard) IsGraphic() bool

IsGraphic tests if the rune is a printable character.

func (Keyboard) Type

func (e Keyboard) Type() int

Type returns the type of the keyboard event.

type Menu struct {
	Action string // Action represents the menu action command
}

Menu represents a menu action event.

func NewMenu

func NewMenu(short string) Menu

NewMenu returns a new menu action event.

func (e Menu) Type() int

Type returns the type of the menu event.

type Motion

type Motion struct {
	Point   image.Point // Point represents the location of the mouse pointer
	Shift   bool        // Shift indicates if the Shift key is pressed during motion
	Control bool        // Control indicates if the Control key is pressed during motion
	Alt     bool        // Alt indicates if the Alt key is pressed during motion
	Meta    bool        // Meta indicates if the Meta key is pressed during motion
}

Motion represents a mouse motion event.

func (Motion) Type

func (e Motion) Type() int

Type returns the type of the motion event.

type Scroll added in v0.2.2

type Scroll struct {
	Direction int // Direction represents the direction of the scroll
	DeltaX    int // DeltaX represents the horizontal scroll delta
	DeltaY    int // DeltaY represents the vertical scroll delta
}

Scroll represents a scroll event.

func (Scroll) Type added in v0.2.2

func (e Scroll) Type() int

Type returns the type of the scroll event.

Jump to

Keyboard shortcuts

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