event/event.go
Functions
func Handled
func (b *Base) Handled() bool {
return b.handled
}
func Modifiers
Modifiers returns the modifier keys held when the event occurred.
func (b *Base) Modifiers() Modifiers {
return b.modifiers
}
func NewBase
NewBase creates a new Base event with the given type and current time.
func NewBase(eventType Type, mods Modifiers) Base {
return Base{
eventType: eventType,
time: time.Now(),
modifiers: mods,
}
}
func NewBaseWithTime
NewBaseWithTime creates a new Base event with the given type and timestamp.
func NewBaseWithTime(eventType Type, t time.Time, mods Modifiers) Base {
return Base{
eventType: eventType,
time: t,
modifiers: mods,
}
}
func SetHandled
SetHandled marks the event as handled, preventing further propagation.
func (b *Base) SetHandled() {
b.handled = true
}
func String
String returns a human-readable name for the event type.
func (t Type) String() string {
switch t {
case TypeMouse:
return typeMouseStr
case TypeKey:
return typeKeyStr
case TypeFocus:
return typeFocusStr
case TypeWheel:
return typeWheelStr
case TypeTouch:
return typeTouchStr
case TypeText:
return typeTextStr
case TypeDrop:
return typeDropStr
case TypeResize:
return typeResizeStr
default:
return unknownStr
}
}
func Time
Time returns when the event occurred.
func (b *Base) Time() time.Time {
return b.time
}
func Type
Type returns the category of this event.
func (b *Base) Type() Type {
return b.eventType
}
Structs
type Base struct
Base provides common fields and methods for all event types.
Embed this struct in concrete event types to inherit the base implementation.
All concrete event types must use pointer receivers to allow SetHandled to work.
type Base struct {
eventType Type
time time.Time
handled bool
modifiers Modifiers
}
Interfaces
type Event interface
Event is the interface implemented by all event types.
Events carry information about user input and can be marked as handled
to prevent further propagation through the widget tree.
type Event interface {
// Type returns the category of this event.
Type() Type
// Time returns when the event occurred.
Time() time.Time
// Handled returns true if the event has been handled.
Handled() bool
// SetHandled marks the event as handled, preventing further propagation.
SetHandled()
// Modifiers returns the modifier keys held when the event occurred.
Modifiers() Modifiers
}
Handled returns true if the event has been handled.