Documentation ¶
Index ¶
- Variables
- type Base
- func (ev *Base) AsBase() *Base
- func (ev *Base) ClearHandled()
- func (ev Base) Clone() Event
- func (ev Base) HasAllModifiers(mods ...enums.BitFlag) bool
- func (ev Base) HasAnyModifier(mods ...enums.BitFlag) bool
- func (ev Base) HasPos() bool
- func (ev *Base) Init()
- func (ev Base) IsHandled() bool
- func (ev Base) IsSame(oth Event) bool
- func (ev Base) IsUnique() bool
- func (ev Base) KeyChord() key.Chord
- func (ev Base) KeyCode() key.Codes
- func (ev Base) KeyRune() rune
- func (ev Base) LocalOff() image.Point
- func (ev Base) LocalPos() image.Point
- func (ev Base) LocalPrevPos() image.Point
- func (ev Base) LocalStartPos() image.Point
- func (ev Base) Modifiers() key.Modifiers
- func (ev Base) MouseButton() Buttons
- func (ev Base) NeedsFocus() bool
- func (ev Base) OnWinFocus() bool
- func (ev Base) Pos() image.Point
- func (ev Base) PrevDelta() image.Point
- func (ev Base) PrevPos() image.Point
- func (ev Base) PrevTime() time.Time
- func (ev Base) SelectMode() SelectModes
- func (ev *Base) SetHandled()
- func (ev *Base) SetLocalOff(off image.Point)
- func (ev *Base) SetModifiers(mods ...enums.BitFlag)
- func (ev *Base) SetTime()
- func (ev *Base) SetUnique()
- func (ev Base) SincePrev() time.Duration
- func (ev Base) SinceStart() time.Duration
- func (ev Base) StartDelta() image.Point
- func (ev Base) StartPos() image.Point
- func (ev Base) StartTime() time.Time
- func (ev Base) String() string
- func (ev Base) Time() time.Time
- func (ev Base) Type() Types
- type Buttons
- func (i Buttons) Desc() string
- func (i Buttons) Int64() int64
- func (i Buttons) IsValid() bool
- func (i Buttons) MarshalText() ([]byte, error)
- func (i *Buttons) SetInt64(in int64)
- func (i *Buttons) SetString(s string) error
- func (i Buttons) String() string
- func (i *Buttons) UnmarshalText(text []byte) error
- func (i Buttons) Values() []enums.Enum
- type CustomEvent
- type Deque
- type DragDrop
- type DropMods
- func (i DropMods) Desc() string
- func (i DropMods) Int64() int64
- func (i DropMods) IsValid() bool
- func (i DropMods) MarshalText() ([]byte, error)
- func (i *DropMods) SetInt64(in int64)
- func (i *DropMods) SetString(s string) error
- func (i DropMods) String() string
- func (i *DropMods) UnmarshalText(text []byte) error
- func (i DropMods) Values() []enums.Enum
- type Event
- type EventFlags
- func (i EventFlags) BitIndexString() string
- func (i EventFlags) Desc() string
- func (i EventFlags) HasFlag(f enums.BitFlag) bool
- func (i EventFlags) Int64() int64
- func (i EventFlags) IsValid() bool
- func (i EventFlags) MarshalText() ([]byte, error)
- func (i *EventFlags) SetFlag(on bool, f ...enums.BitFlag)
- func (i *EventFlags) SetInt64(in int64)
- func (i *EventFlags) SetString(s string) error
- func (i *EventFlags) SetStringOr(s string) error
- func (i EventFlags) String() string
- func (i *EventFlags) UnmarshalText(text []byte) error
- func (i EventFlags) Values() []enums.Enum
- type Key
- type Listeners
- type Mgr
- func (em *Mgr) Custom(data any)
- func (em *Mgr) Key(typ Types, rn rune, code key.Codes, mods key.Modifiers)
- func (em *Mgr) KeyChord(rn rune, code key.Codes, mods key.Modifiers)
- func (em *Mgr) Magnify(scaleFactor float32, where image.Point)
- func (em *Mgr) MouseButton(typ Types, but Buttons, where image.Point, mods key.Modifiers)
- func (em *Mgr) MouseMove(where image.Point)
- func (em *Mgr) Scroll(where, delta image.Point)
- func (em *Mgr) Touch(typ Types, seq Sequence, where image.Point)
- func (em *Mgr) Window(act WinActions)
- func (em *Mgr) WindowPaint()
- func (em *Mgr) WindowResize()
- type MgrState
- type Mouse
- type MouseScroll
- type OSEvent
- type OSFiles
- type SelectModes
- func (i SelectModes) Desc() string
- func (i SelectModes) Int64() int64
- func (i SelectModes) IsValid() bool
- func (i SelectModes) MarshalText() ([]byte, error)
- func (i *SelectModes) SetInt64(in int64)
- func (i *SelectModes) SetString(s string) error
- func (i SelectModes) String() string
- func (i *SelectModes) UnmarshalText(text []byte) error
- func (i SelectModes) Values() []enums.Enum
- type Sequence
- type Touch
- type TouchMagnify
- type Types
- func (i Types) Desc() string
- func (i Types) Int64() int64
- func (tp Types) IsDrag() bool
- func (tp Types) IsKey() bool
- func (tp Types) IsMouse() bool
- func (tp Types) IsSlide() bool
- func (tp Types) IsTouch() bool
- func (i Types) IsValid() bool
- func (tp Types) IsWindow() bool
- func (i Types) MarshalText() ([]byte, error)
- func (i *Types) SetInt64(in int64)
- func (i *Types) SetString(s string) error
- func (i Types) String() string
- func (i *Types) UnmarshalText(text []byte) error
- func (i Types) Values() []enums.Enum
- type WinActions
- func (i WinActions) Desc() string
- func (i WinActions) Int64() int64
- func (i WinActions) IsValid() bool
- func (i WinActions) MarshalText() ([]byte, error)
- func (i *WinActions) SetInt64(in int64)
- func (i *WinActions) SetString(s string) error
- func (i WinActions) String() string
- func (i *WinActions) UnmarshalText(text []byte) error
- func (i WinActions) Values() []enums.Enum
- type WindowEvent
Constants ¶
This section is empty.
Variables ¶
var ( // DoubleClickInterval is the maximum time interval between button press // events to count as a double-click. // This is also in gi.Prefs and updated from there. DoubleClickInterval = 500 * time.Millisecond // ScrollWheelSpeed controls how fast the scroll wheel moves (typically // interpreted as pixels per wheel step) -- only relevant for some OS's which // do not have a native preference for this setting, e.g., X11 // This is also in gi.Prefs and updated from there ScrollWheelSpeed = float32(20) )
var TraceEventCompression = false
TraceEventCompression can be set to true to see when events are being compressed to eliminate laggy behavior.
var TraceWindowPaint = false
TraceWindowPaint prints out a . for each WindowPaint event - for other window events, * for mouse move events. Makes it easier to see what is going on in the overall flow.
Functions ¶
This section is empty.
Types ¶
type Base ¶
type Base struct { // Typ is the type of event, returned as Type() Typ Types // Flags records event boolean state, using atomic flag operations Flags EventFlags // GenTime records the time when the event was first generated, using more // efficient nptime struct GenTime nptime.Time // Key Modifiers present when event occurred: for Key, Mouse, Touch events Mods key.Modifiers // Where is the window-based position in raw display dots // (pixels) where event took place. Where image.Point // Start is the window-based starting position in raw display dots // (pixels) where event started. Start image.Point // Prev is the window-based previous position in raw display dots // (pixels) -- e.g., for mouse dragging. Prev image.Point // StTime is the starting time, using more efficient nptime struct StTime nptime.Time // PrvTime is the time of the previous event, using more efficient nptime struct PrvTime nptime.Time // LocalOffset is the offset subtracted from original window coordinates // to compute the local coordinates. LocalOffset image.Point // WhereLocal is the local position, which can be adjusted from the window pos // via SubLocalOffset based on a local top-left coordinate for a region within // the window. WhereLocal image.Point // StartLocal is the local starting position StartLocal image.Point // PrevLocal is the local previous position PrevLocal image.Point // Button is the mouse button being pressed or released, for relevant events. Button Buttons // Rune is the meaning of the key event as determined by the // operating system. The mapping is determined by system-dependent // current layout, modifiers, lock-states, etc. Rune rune // Code is the identity of the physical key relative to a notional // "standard" keyboard, independent of current layout, modifiers, // lock-states, etc Code key.Codes // todo: add El info Data any }
Base is the base type for events. It is designed to support most event types so no further subtypes are needed.
func (*Base) ClearHandled ¶
func (ev *Base) ClearHandled()
func (Base) HasAllModifiers ¶
HasAllModifiers tests whether all of given modifier(s) were set
func (Base) KeyChord ¶
KeyChord returns a string representation of the keyboard event suitable for keyboard function maps, etc. Printable runes are sent directly, and non-printable ones are converted to their corresponding code names without the "Code" prefix.
func (Base) LocalPrevPos ¶
func (Base) LocalStartPos ¶
func (Base) MouseButton ¶
MouseButton is the mouse button being pressed or released, for relevant events.
func (Base) NeedsFocus ¶
func (Base) OnWinFocus ¶
func (Base) SelectMode ¶
func (ev Base) SelectMode() SelectModes
SelectMode returns the selection mode based on given modifiers on event
func (*Base) SetHandled ¶
func (ev *Base) SetHandled()
func (*Base) SetLocalOff ¶
func (*Base) SetModifiers ¶
SetModifiers sets the bitflags based on a list of key.Modifiers
func (Base) SinceStart ¶
func (Base) StartDelta ¶
type Buttons ¶
type Buttons int32 //enums:enum
Buttons is a mouse button.
const ButtonsN Buttons = 4
ButtonsN is the highest valid value for type Buttons, plus one.
func ButtonsValues ¶
func ButtonsValues() []Buttons
ButtonsValues returns all possible values for the type Buttons.
func (Buttons) MarshalText ¶
MarshalText implements the encoding.TextMarshaler interface.
func (*Buttons) SetString ¶
SetString sets the Buttons value from its string representation, and returns an error if the string is invalid.
func (*Buttons) UnmarshalText ¶
UnmarshalText implements the encoding.TextUnmarshaler interface.
type CustomEvent ¶
CustomEvent is a user-specified event that can be sent and received as needed, and contains a Data field for arbitrary data, and optional position and focus parameters
func (CustomEvent) HasPos ¶
func (ce CustomEvent) HasPos() bool
func (CustomEvent) String ¶
func (ce CustomEvent) String() string
type Deque ¶
type Deque struct { Back []Event // FIFO. Front []Event // LIFO. Mu sync.Mutex Cond sync.Cond // Cond.L is lazily initialized to &Deque.Mu. }
Dequer is an infinitely buffered double-ended queue of events. If an event is not marked as Unique, and the last event in the queue is of the same type, then the new one replaces the last one. This automatically implements event compression to manage the common situation where event processing is slower than event generation, such as with Mouse movement and Paint events. The zero value is usable, but a Deque value must not be copied.
func (*Deque) LockAndInit ¶
func (q *Deque) LockAndInit()
func (*Deque) NextEvent ¶
NextEvent returns the next event in the deque. It blocks until such an event has been sent.
func (*Deque) PollEvent ¶
PollEvent returns the next event in the deque if available, and returns true. If none are available, it returns false immediately.
type DragDrop ¶ added in v0.0.15
type DragDrop struct { Base // When event is received by target, DropMod indicates the suggested modifier // action associated with the drop (affected by holding down modifier // keys), suggesting what to do with the dropped item, where appropriate. // Receivers can ignore or process in their own relevant way as needed, // BUT it is essential to update the event with the actual type of Mod // action taken, because the event will be sent back to the source with // this Mod as set by the receiver. The main consequence is that a // DropMove requires the drop source to delete itself once the event has // been received, otherwise it (typically) doesn't do anything, so just // be careful about that particular case. DropMod DropMods // Data contains the data from the Source of the drag, // typically a mimedata encoded representation. Data any // Source of the drop -- only available for internal DND actions Source any // Target of the drop -- receiver of an accepted drop should set this to // itself, so Source (if internal) can see who got it Target any }
DragDrop represents the drag-and-drop Drop event
func NewDragDrop ¶ added in v0.0.15
func (*DragDrop) DefaultMod ¶ added in v0.0.15
func (e *DragDrop) DefaultMod()
DefaultMod sets the default DropMod modifier action based on modifier keys
type DropMods ¶
type DropMods int32 //enums:enum -trim-prefix Drop
DropMods indicates the modifier associated with the drop action (affected by holding down modifier keys), suggesting what to do with the dropped item, where appropriate
const ( NoDropMod DropMods = iota // Copy is the default and implies data is just copied -- receiver can do // with it as they please and source does not need to take any further // action DropCopy // Move is signaled with a Shift or Meta key (by default) and implies that // the source should delete itself when it receives the DropFmSource event // action with this Mod value set -- receiver must update the Mod to // reflect actual action taken, and be particularly careful with this one DropMove // Link can be any other kind of alternative action -- link is applicable // to files (symbolic link) DropLink // Ignore means that the receiver chose to not process this drop DropIgnore )
const DropModsN DropMods = 5
DropModsN is the highest valid value for type DropMods, plus one.
func DefaultModBits ¶
DefaultModBits returns the default DropMod modifier action based on modifier keys
func DropModsValues ¶
func DropModsValues() []DropMods
DropModsValues returns all possible values for the type DropMods.
func (DropMods) MarshalText ¶
MarshalText implements the encoding.TextMarshaler interface.
func (*DropMods) SetString ¶
SetString sets the DropMods value from its string representation, and returns an error if the string is invalid.
func (*DropMods) UnmarshalText ¶
UnmarshalText implements the encoding.TextUnmarshaler interface.
type Event ¶
type Event interface { fmt.Stringer // Type returns the type of event associated with given event Type() Types // AsBase returns this event as a Base event type, // which is used for most Event types. AsBase() *Base // IsUnique returns true if this event must always be sent, // even if the last event sent is of the same type. // This is true for Key, MouseButton, // Otherwise, events of the same type are compressed // such that if the last one written to the queue is of // the same type, it is replaced instead of adding a new one. IsUnique() bool // NeedsFocus this event goes to current focus widget NeedsFocus() bool // HasPos returns true if the event has a window position where it takes place HasPos() bool // Pos returns the original window-based position in raw display dots // (pixels) where event took place. Pos() image.Point // SetLocalOff sets the offset subtracted from window-based positions // to compute Local versions of positions, which are updated. SetLocalOff(off image.Point) // LocalOff returns the offset subtracted from window-based positions // to compute Local versions of positions. LocalOff() image.Point // LocalPos returns the local position, // which can be adjusted from the window pos // via SubLocalOffset based on a local top-left // coordinate for a region within the window. LocalPos() image.Point // StartPos returns the starting (MouseDown) window-based position. StartPos() image.Point // LocalStartPos returns the starting (MouseDown) local position LocalStartPos() image.Point // StartDelta returns Pos - Start StartDelta() image.Point // PrevPos returns the previous (MouseMove/Drag) window-based position. PrevPos() image.Point // LocalPrevPos returns the previous (MouseMove/Drag) local position LocalPrevPos() image.Point // PrevDelta returns Pos - Prev PrevDelta() image.Point // Time returns the time at which the event was generated, in UnixNano nanosecond units Time() time.Time // StartTime returns time of StartPos (MouseDown), // or other starting time of relevance to the event. StartTime() time.Time // SinceStart returns Time().Sub(StartTime()) -- duration since Start SinceStart() time.Duration // PrevTime returns time of PrevPos (MouseMove), // or other earlier time of relevance to the event. PrevTime() time.Time // SincePrev returns Time().Sub(PrevTime()) -- duration since Prev SincePrev() time.Duration // IsHandled returns whether this event has already been processed // Event handling checks this and terminates processing if // SetHandled has been called. IsHandled() bool // SetHandled marks the event as having been processed, // so no further processing occurs. This can accomplish // the same effect as PreventDefault function in JavaScript. SetHandled() // Init sets the time to now, and any other initialization. // Done just prior to event Send. Init() // Clone returns a duplicate of this event with the basic event parameters // copied (specialized Event types have their own CloneX methods) // and the Handled flag is reset. This is suitable for repurposing. Clone() Event // SetTime sets the event time to Now SetTime() // IsSame returns true if the current event is the same as other. // Checks Type and, where relevant, Action. IsSame(oth Event) bool // MouseButton is the mouse button being pressed or released, for relevant events. MouseButton() Buttons // SelectMode returns the selection mode based on given modifiers on event SelectMode() SelectModes // Modifiers returns the modifier keys present at time of event Modifiers() key.Modifiers // HasAllModifiers tests whether all of given modifier(s) were set HasAllModifiers(mods ...enums.BitFlag) bool // HasAnyModifier testes whether any of the given modifiers were set HasAnyModifier(mods ...enums.BitFlag) bool // Rune is the meaning of the key event as determined by the // operating system. The mapping is determined by system-dependent // current layout, modifiers, lock-states, etc. KeyRune() rune // Code is the identity of the physical key relative to a notional // "standard" keyboard, independent of current layout, modifiers, // lock-states, etc // // For standard key codes, its value matches USB HID key codes. // Compare its value to uint32-typed constants in this package, such // as CodeLeftShift and CodeEscape. // // Pressing the regular '2' key and number-pad '2' key (with Num-Lock) // generate different Codes (but the same Rune). KeyCode() key.Codes // KeyChord returns a string representation of the keyboard event suitable for // keyboard function maps, etc. Printable runes are sent directly, and // non-printable ones are converted to their corresponding code names without // the "Code" prefix. KeyChord() key.Chord }
Event is the interface for goosi GUI events. also includes Stringer to get a string description of the event
type EventFlags ¶
type EventFlags int64 //enums:bitflag
EventFlags encode boolean event properties
const ( // Handled indicates that the event has been handled Handled EventFlags = iota // EventUnique indicates that the event is Unique and not // to be compressed with like events. Unique )
const EventFlagsN EventFlags = 2
EventFlagsN is the highest valid value for type EventFlags, plus one.
func EventFlagsValues ¶
func EventFlagsValues() []EventFlags
EventFlagsValues returns all possible values for the type EventFlags.
func (EventFlags) BitIndexString ¶
func (i EventFlags) BitIndexString() string
BitIndexString returns the string representation of this EventFlags value if it is a bit index value (typically an enum constant), and not an actual bit flag value.
func (EventFlags) Desc ¶
func (i EventFlags) Desc() string
Desc returns the description of the EventFlags value.
func (EventFlags) HasFlag ¶
func (i EventFlags) HasFlag(f enums.BitFlag) bool
HasFlag returns whether these bit flags have the given bit flag set.
func (EventFlags) Int64 ¶
func (i EventFlags) Int64() int64
Int64 returns the EventFlags value as an int64.
func (EventFlags) IsValid ¶
func (i EventFlags) IsValid() bool
IsValid returns whether the value is a valid option for type EventFlags.
func (EventFlags) MarshalText ¶
func (i EventFlags) MarshalText() ([]byte, error)
MarshalText implements the encoding.TextMarshaler interface.
func (*EventFlags) SetFlag ¶
func (i *EventFlags) SetFlag(on bool, f ...enums.BitFlag)
SetFlag sets the value of the given flags in these flags to the given value.
func (*EventFlags) SetInt64 ¶
func (i *EventFlags) SetInt64(in int64)
SetInt64 sets the EventFlags value from an int64.
func (*EventFlags) SetString ¶
func (i *EventFlags) SetString(s string) error
SetString sets the EventFlags value from its string representation, and returns an error if the string is invalid.
func (*EventFlags) SetStringOr ¶
func (i *EventFlags) SetStringOr(s string) error
SetStringOr sets the EventFlags value from its string representation while preserving any bit flags already set, and returns an error if the string is invalid.
func (EventFlags) String ¶
func (i EventFlags) String() string
String returns the string representation of this EventFlags value.
func (*EventFlags) UnmarshalText ¶
func (i *EventFlags) UnmarshalText(text []byte) error
UnmarshalText implements the encoding.TextUnmarshaler interface.
func (EventFlags) Values ¶
func (i EventFlags) Values() []enums.Enum
Values returns all possible values for the type EventFlags.
type Key ¶
type Key struct {
Base
}
events.Key is a low-level immediately-generated key event, tracking press and release of keys -- suitable for fine-grained tracking of key events -- see also events.Key for events that are generated only on key press, and that include the full chord information about all the modifier keys that were present when a non-modifier key was released
func (*Key) NeedsFocus ¶
type Listeners ¶
Listeners registers lists of event listener functions to receive different event types. Listeners are closure methods with all context captured. Functions are called in *reverse* order of when they are added: First In, Last Called, so that "base" functions are typically added first, and then can be overridden by later-added ones. Call SetHandled() on the event to stop further propagation.
func (*Listeners) Add ¶
Add adds a function for given type, to the end of the current stack, so that it will be called before everything else already on the stack.
func (*Listeners) AddLastCall ¶ added in v0.0.6
AddLastCall adds a function for given type, to the start of the current stack, so that it will be called *after* everything else on the stack.
func (*Listeners) Call ¶
Call calls all functions for given event. It goes in _reverse_ order to the last functions added are the first called and it stops when the event is marked as Handled. This allows for a natural and optional override behavior, as compared to requiring more complex priority-based mechanisms.
type Mgr ¶
type Mgr struct { // Deque is the event queue Deque Deque // flag for ignoring mouse events when disabling mouse movement ResettingPos bool // Last has the prior state for key variables Last MgrState // PaintCount is used for printing paint events as . PaintCount int }
Mgr manages the event construction and sending process, for its parent window. Caches state as needed to generate derived events such as MouseDrag.
func (*Mgr) Magnify ¶ added in v0.0.6
Magnify creates and sends a TouchMagnify event with the given values.
func (*Mgr) MouseButton ¶
MouseButton creates and sends a mouse button event with given values
func (*Mgr) Touch ¶
Touch creates and sends a touch event with the given values. It also creates and sends a corresponding mouse event.
func (*Mgr) Window ¶
func (em *Mgr) Window(act WinActions)
func (*Mgr) WindowPaint ¶
func (em *Mgr) WindowPaint()
func (*Mgr) WindowResize ¶
func (em *Mgr) WindowResize()
type MgrState ¶
type MgrState struct { // last mouse button event type (down or up) MouseButtonType Types // last mouse button MouseButton Buttons // time of MouseDown MouseDownTime nptime.Time // position at MouseDown MouseDownPos image.Point // button at MouseDown MouseDownButton Buttons // time of Click event -- for double-click ClickTime nptime.Time // position of mouse from move events MousePos image.Point // time of last move MouseMoveTime nptime.Time // keyboard modifiers (Shift, Alt, etc) Mods key.Modifiers // Key event code Key key.Codes }
MgrState tracks basic event state over time to enable recognition and full data for generating events.
type Mouse ¶
type Mouse struct {
Base
}
Mouse is a basic mouse event for all mouse events except Scroll
func NewMouseDrag ¶
func NewMouseMove ¶
type MouseScroll ¶
type MouseScroll struct { Mouse // Delta is the amount of scrolling in each axis Delta image.Point }
MouseScroll is for mouse scrolling, recording the delta of the scroll
func (MouseScroll) DimDelta ¶
func (ev MouseScroll) DimDelta(dim mat32.Dims) int
DimDelta returns the scrolling delta change for the given axis. for X dimension, it returns any non-zero Y delta because often scroll wheels only report Y deltas.
func (*MouseScroll) String ¶
func (ev *MouseScroll) String() string
type OSFiles ¶
osevent.OpenFilesEvent is for OS open files action to open given files
func NewOSFiles ¶
type SelectModes ¶
type SelectModes int32 //enums:enum
SelectModes interprets the modifier keys to determine what type of selection mode to use. This is also used for selection actions and has modes not directly activated by modifier keys.
const ( // SelectOne selects a single item, and is the default when no modifier key // is pressed SelectOne SelectModes = iota // ExtendContinuous, activated by Shift key, extends the selection to // select a continuous region of selected items, with no gaps ExtendContinuous // ExtendOne, activated by Control or Meta / Command, extends the // selection by adding the one additional item just clicked on, creating a // potentially discontinuous set of selected items ExtendOne // NoSelect means do not update selection -- this is used programmatically // and not available via modifier key NoSelect // Unselect means unselect items -- this is used programmatically // and not available via modifier key -- typically ExtendOne will // unselect if already selected Unselect // SelectQuiet means select without doing other updates or signals -- for // bulk updates with a final update at the end -- used programmatically SelectQuiet // UnselectQuiet means unselect without doing other updates or signals -- for // bulk updates with a final update at the end -- used programmatically UnselectQuiet )
const SelectModesN SelectModes = 7
SelectModesN is the highest valid value for type SelectModes, plus one.
func SelectModeBits ¶
func SelectModeBits(mods key.Modifiers) SelectModes
SelectModeBits returns the selection mode based on given modifiers bitflags
func SelectModesValues ¶
func SelectModesValues() []SelectModes
SelectModesValues returns all possible values for the type SelectModes.
func (SelectModes) Desc ¶
func (i SelectModes) Desc() string
Desc returns the description of the SelectModes value.
func (SelectModes) Int64 ¶
func (i SelectModes) Int64() int64
Int64 returns the SelectModes value as an int64.
func (SelectModes) IsValid ¶
func (i SelectModes) IsValid() bool
IsValid returns whether the value is a valid option for type SelectModes.
func (SelectModes) MarshalText ¶
func (i SelectModes) MarshalText() ([]byte, error)
MarshalText implements the encoding.TextMarshaler interface.
func (*SelectModes) SetInt64 ¶
func (i *SelectModes) SetInt64(in int64)
SetInt64 sets the SelectModes value from an int64.
func (*SelectModes) SetString ¶
func (i *SelectModes) SetString(s string) error
SetString sets the SelectModes value from its string representation, and returns an error if the string is invalid.
func (SelectModes) String ¶
func (i SelectModes) String() string
String returns the string representation of this SelectModes value.
func (*SelectModes) UnmarshalText ¶
func (i *SelectModes) UnmarshalText(text []byte) error
UnmarshalText implements the encoding.TextUnmarshaler interface.
func (SelectModes) Values ¶
func (i SelectModes) Values() []enums.Enum
Values returns all possible values for the type SelectModes.
type Touch ¶
type Touch struct { Base // Sequence is the sequence number. The same number is shared by all events // in a sequence. A sequence begins with a single Begin, is followed by // zero or more Moves, and ends with a single End. A Sequence // distinguishes concurrent sequences but its value is subsequently reused. Sequence Sequence }
Touch is a touch event.
type TouchMagnify ¶ added in v0.0.6
type TouchMagnify struct { Touch // the multiplicative scale factor relative to the previous // zoom of the screen ScaleFactor float32 }
TouchMagnify is a touch magnification (scaling) gesture event. It is the event struct corresponding to events of type Magnify.
func NewMagnify ¶ added in v0.0.6
func NewMagnify(scaleFactor float32, where image.Point) *TouchMagnify
NewMagnify creates a new TouchMagnify event based on the given multiplicative scale factor.
type Types ¶
type Types int32 //enums:enum
Types determines the type of GUI event, and also the level at which one can select which events to listen to. The type should include both the source / nature of the event and the "action" type of the event (e.g., MouseDown, MouseUp are separate event types). The standard [JavaScript Event](https://developer.mozilla.org/en-US/docs/Web/Events) provide the basis for most of the event type names and categories. Most events use the same Base type and only need to set relevant fields and the type. Unless otherwise noted, all events are marked as Unique, meaning they are always sent. Non-Unique events are subject to compression, where if the last event added (and not yet processed and therefore removed from the queue) is of the same type then it is replaced with the new one, instead of adding.
const ( // zero value is an unknown type UnknownType Types = iota // MouseDown happens when a mouse button is pressed down. // See MouseButton() for which. // See Click for a synthetic event representing a MouseDown // followed by MouseUp on the same element with Left (primary) // mouse button. Often that is the most useful. MouseDown // MouseUp happens when a mouse button is released. // See MouseButton() for which. MouseUp // MouseMove is always sent when the mouse is moving but no // button is down, even if there might be other higher-level events too. // These can be numerous and thus it is typically more efficient // to listen to other events derived from this. // Not unique, and Prev position is updated during compression. MouseMove // MouseDrag is always sent when the mouse is moving and there // is a button down, even if there might be other higher-level // events too. // The start pos indicates where (and when) button first was pressed. // Not unique and Prev position is updated during compression. MouseDrag // Click represents a MouseDown followed by MouseUp // in sequence on the same element, with the Left (primary) button. // This is the typical event for most basic user interaction. Click // DoubleClick represents two Click events in a row in rapid // succession. DoubleClick // ContextMenu represents a MouseDown/Up event with the // Right mouse button (which is also activated by // Control key + Left Click). ContextMenu // LongPressStart is when the mouse has been relatively stable // after MouseDown on an element for a minimum duration (500 msec default). LongPressStart // LongPressEnd is sent after LongPressStart when the mouse has // gone up, moved sufficiently, left the current element, // or another input event has happened. LongPressEnd // MouseEnter is when the mouse enters the bounding box // of a new element. It is used for setting the Hover state, // and can trigger cursor changes. // See DragEnter for alternative case during Drag events. MouseEnter // MouseLeave is when the mouse leaves the bounding box // of an element, that previously had a MouseEnter event. // Given that elements can have overlapping bounding boxes // (e.g., child elements within a container), it is not the case // that a MouseEnter on a child triggers a MouseLeave on // surrounding containers. // See DragLeave for alternative case during Drag events. MouseLeave // LongHoverStart is when the mouse has been relatively stable // after MouseEnter on an element for a minimum duration // (500 msec default). // This triggers the LongHover state typically used for Tooltips. LongHoverStart // LongHoverEnd is after LongHoverStart when the mouse has // moved sufficiently, left the current element, // or another input event has happened, // thereby terminating the LongHover state. LongHoverEnd // DragStart is at the start of a drag-n-drop event sequence, when // a Draggable element is Active and a sufficient distance of // MouseDrag events has occurred to engage the DragStart event. DragStart // DragMove is for a MouseDrag event during the drag-n-drop sequence. // Usually don't need to listen to this one. MouseDrag is also sent. DragMove // DragEnter is like MouseEnter but after a DragStart during a // drag-n-drop sequence. MouseEnter is not sent in this case. DragEnter // DragLeave is like MouseLeave but after a DragStart during a // drag-n-drop sequence. MouseLeave is not sent in this case. DragLeave // Drop is sent when an item being Dragged is dropped on top of a // target element. The event struct should be DragDrop. Drop // DropDeleteSource is sent to the source Drag element if the // Drag-n-Drop event is a Move type, which requires deleting // the source element. The event struct should be DragDrop. DropDeleteSource // SlideStart is for a Slideable element when Active and a // sufficient distance of MouseDrag events has occurred to // engage the SlideStart event. Sets the Sliding state. SlideStart // SlideMove is for a Slideable element after SlideStart // is being dragged via MouseDrag events. SlideMove // SlideStop is when the mouse button is released on a Slideable // element being dragged via MouseDrag events. This typically // also accompanied by a Changed event for the new slider value. SlideStop // Scroll is for scroll wheel or other scrolling events (gestures). // These are not unique and Delta is updated during compression. Scroll // KeyDown is when a key is pressed down. // This provides fine-grained data about each key as it happens. // KeyChord is recommended for a more complete Key event. KeyDown // KeyUp is when a key is released. // This provides fine-grained data about each key as it happens. // KeyChord is recommended for a more complete Key event. KeyUp // KeyChord is only generated when a non-modifier key is released, // and it also contains a string representation of the full chord, // suitable for translation into keyboard commands, emacs-style etc. // It can be somewhat delayed relative to the KeyUp. KeyChord // TouchStart is when a touch event starts, for the low-level touch // event processing. TouchStart also activates MouseDown, Scroll, // Magnify, or Rotate events depending on gesture recognition. TouchStart // TouchEnd is when a touch event ends, for the low-level touch // event processing. TouchEnd also activates MouseUp events // depending on gesture recognition. TouchEnd // TouchMove is when a touch event moves, for the low-level touch // event processing. TouchMove also activates MouseMove, Scroll, // Magnify, or Rotate events depending on gesture recognition. TouchMove // Magnify is a touch-based magnify event (e.g., pinch) Magnify // Rotate is a touch-based rotate event. Rotate // Select is sent for any direction of selection change // on (or within if relevant) a Selectable element. // Typically need to query the element(s) to determine current // selection state. Select // Focus is sent when Focsable element receives Focus Focus // FocusLost is sent when Focsable element loses Focus FocusLost // Change is when a value represented by the element has been changed // by the user and committed (for example, someone has typed text in a // textfield and then pressed enter). This is *not* triggered when // the value has not been committed; see [Input] for that. // This is for Editable, Checkable, and Slidable items. Change // Input is when a value represented by the element has changed, but // has not necessarily been committed (for example, this triggers each // time someone presses a key in a text field). This *is* triggered when // the value has not been committed; see [Change] for a version that only // occurs when the value is committed. // This is for Editable, Checkable, and Slidable items. Input // Show is generated by an overall Scene or Window level container when // the content is first shown to the user in its final form. // Listening to this event enables other elements to perform initial // one-time activities on startup, in the context of a fully rendered // display. Show // Close is generated by an overall Scene or Window level container when // being closed (e.g., on dialog closing). This is an opportunity to save // unsaved edits, for example. Close // Window reports on changes in the window position, // visibility (iconify), focus changes, screen update, and closing. // These are only sent once per event (Unique). Window // WindowResize happens when the window has been resized, // which can happen continuously during a user resizing // episode. These are not Unique events, and are compressed // to minimize lag. WindowResize // WindowPaint is sent continuously at FPS frequency // (60 frames per second by default) to drive updating check // on the window. It is not unique, will be compressed // to keep pace with updating. WindowPaint // OS is an operating system generated event (app level typically) OS // OSOpenFiles is an event telling app to open given files OSOpenFiles // Custom is a user-defined event with a data any field Custom )
const TypesN Types = 45
TypesN is the highest valid value for type Types, plus one.
func TypesValues ¶
func TypesValues() []Types
TypesValues returns all possible values for the type Types.
func (Types) MarshalText ¶
MarshalText implements the encoding.TextMarshaler interface.
func (*Types) SetString ¶
SetString sets the Types value from its string representation, and returns an error if the string is invalid.
func (*Types) UnmarshalText ¶
UnmarshalText implements the encoding.TextUnmarshaler interface.
type WinActions ¶
type WinActions int32 //enums:enum -trim-prefix Win
WinActions is the action taken on the window by the user.
const ( // NoWinAction is the zero value for special types (Resize, Paint) NoWinAction WinActions = iota // WinClose means that the window is about to close, but has not yet closed. WinClose // WinMinimize means that the window has been iconified / miniaturized / is no // longer visible. WinMinimize // WinMove means that the window was moved but NOT resized or changed in any // other way -- does not require a redraw, but anything tracking positions // will want to update. WinMove // WinFocus indicates that the window has been activated for receiving user // input. WinFocus // WinFocusLost indicates that the window is no longer activated for // receiving input. WinFocusLost // WinShow is for the WindowShow event -- sent by the system shortly // after the window has opened, to ensure that full rendering // is completed with the proper size, and to trigger one-time actions such as // configuring the main menu after the window has opened. WinShow // ScreenUpdate occurs when any of the screen information is updated // This event is sent to the first window on the list of active windows // and it should then perform any necessary updating ScreenUpdate )
const WinActionsN WinActions = 8
WinActionsN is the highest valid value for type WinActions, plus one.
func WinActionsValues ¶
func WinActionsValues() []WinActions
WinActionsValues returns all possible values for the type WinActions.
func (WinActions) Desc ¶
func (i WinActions) Desc() string
Desc returns the description of the WinActions value.
func (WinActions) Int64 ¶
func (i WinActions) Int64() int64
Int64 returns the WinActions value as an int64.
func (WinActions) IsValid ¶
func (i WinActions) IsValid() bool
IsValid returns whether the value is a valid option for type WinActions.
func (WinActions) MarshalText ¶
func (i WinActions) MarshalText() ([]byte, error)
MarshalText implements the encoding.TextMarshaler interface.
func (*WinActions) SetInt64 ¶
func (i *WinActions) SetInt64(in int64)
SetInt64 sets the WinActions value from an int64.
func (*WinActions) SetString ¶
func (i *WinActions) SetString(s string) error
SetString sets the WinActions value from its string representation, and returns an error if the string is invalid.
func (WinActions) String ¶
func (i WinActions) String() string
String returns the string representation of this WinActions value.
func (*WinActions) UnmarshalText ¶
func (i *WinActions) UnmarshalText(text []byte) error
UnmarshalText implements the encoding.TextUnmarshaler interface.
func (WinActions) Values ¶
func (i WinActions) Values() []enums.Enum
Values returns all possible values for the type WinActions.
type WindowEvent ¶
type WindowEvent struct { Base // Action taken on the window -- what has changed. // Window state fields have current values. Action WinActions }
WindowEvent reports on actions taken on a window. The goosi.Window Flags and other state information will always be updated prior to this event being sent, so those should be consulted directly for the new current state.
func NewWindow ¶
func NewWindow(act WinActions) *WindowEvent
func NewWindowPaint ¶
func NewWindowPaint() *WindowEvent
func NewWindowResize ¶
func NewWindowResize() *WindowEvent
func (*WindowEvent) HasPos ¶
func (ev *WindowEvent) HasPos() bool
func (*WindowEvent) String ¶
func (ev *WindowEvent) String() string