Documentation
¶
Overview ¶
Package event defines the typed events that flow through the vigo view tree: keyboard, mouse, commands, broadcasts, idle ticks, and resize.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Class ¶
type Class uint16
Class is the kind of an event. The zero value, ClassNothing, marks an event as consumed; views call (*Event).Clear when they handle one.
const ( ClassKey Class = 1 << iota ClassMouseDown ClassMouseUp ClassMouseMove ClassMouseAuto ClassMouseWheel ClassCommand ClassBroadcast ClassIdle ClassResize )
Event class flags.
const ClassNothing Class = 0
ClassNothing is the consumed marker. All other classes are bit flags so callers can build masks (e.g. an event filter for mouse events only).
type CommandID ¶
type CommandID uint16
CommandID is a numeric identifier for a UI action: file open, save, quit, menu activate, and so on. Commands let views send actions without knowing who handles them.
type Event ¶
type Event struct {
What Class
Key KeyEvent
Mouse MouseEvent
Msg MessageEvent
}
Event is the union type carried through the event loop. Only the field indicated by What is meaningful; the others are zero. Events are passed by pointer so handlers can mark them consumed via Clear.
type Key ¶
type Key uint16
Key identifies a non-printable key, or KeyRune for printable input where the rune lives in KeyEvent.Rune.
const ( KeyNone Key = iota KeyRune KeyEnter KeyEsc KeyTab KeyShiftTab KeyBackspace KeyDelete KeyInsert KeyHome KeyEnd KeyPgUp KeyPgDn KeyArrowUp KeyArrowDown KeyArrowLeft KeyArrowRight KeyF1 KeyF2 KeyF3 KeyF4 KeyF5 KeyF6 KeyF7 KeyF8 KeyF9 KeyF10 KeyF11 KeyF12 )
Key constants. Function keys, navigation, and KeyRune for printable text.
type MessageEvent ¶
MessageEvent is the payload of ClassCommand and ClassBroadcast events. Info is an optional typed payload; consumers type-assert as needed.
type MouseButton ¶
type MouseButton uint8
MouseButton is a bitmask of mouse buttons currently pressed.
const ( MouseLeft MouseButton = 1 << iota MouseMiddle MouseRight MouseWheelUp MouseWheelDown )
Mouse button bits.
type MouseEvent ¶
type MouseEvent struct {
X, Y int
Buttons MouseButton
Mod Modifier
}
MouseEvent is the payload of any Mouse* event. For Resize events, X and Y carry the new screen width and height (no other field is meaningful).