Documentation ¶
Overview ¶
Package mechuievent collects certain UI events from clients such as keyboard key events, mouse move events, and ShutterbugPixels' overlayer clicks. The semantic meaning of these kinds of events is not known by the client and is determined by the server.
Events from sidebar buttons and sidebar popup panels are dealt with by a different package.
Index ¶
- func NewEventHandleFunc(clr *Collector, shutterbugs mechshutterbug.Containser) http.HandlerFunc
- type ButtonClick
- type ButtonClicks
- type Collection
- type Collections
- type Collector
- func (clr *Collector) ClearShutterbug(shutterbug string) dryad.Set[string]
- func (clr *Collector) Close(reason string)
- func (clr *Collector) Collections() Collections
- func (clr *Collector) RemoveShutterbug(shutterbug, reason string)
- func (clr *Collector) RemoveSource(src string, reason string)
- func (clr *Collector) Sources() dryad.Set[string]
- type Event
- type InOrderEvent
- type KeyboardEvent
- type MechaneButtonEvent
- type MechaneTextfieldKeyUpOrDownEvent
- type MouseButtonEvent
- type MouseMoveEvent
- type MouseWheelEvent
- type TextfieldKeys
- type WheelMoves
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewEventHandleFunc ¶
func NewEventHandleFunc( clr *Collector, shutterbugs mechshutterbug.Containser, ) http.HandlerFunc
NewEventHandleFunc creates a HTTP request handler which allows clients to interface with the collector.
The handler upgrades the HTTP request to a websocket and accepts UI events, one per websocket message. The websocket's first ever message should be a valid shutterbug.
Types ¶
type ButtonClick ¶
type ButtonClick struct { MechaneButtonEvent Shutterbug string }
ButtonClick event on a mechane-button element from an input source associated with a particular shutterbug.
type ButtonClicks ¶
type ButtonClicks struct { *dryad.SyncAwaitSeq[ButtonClick] }
ButtonClicks is a sequence of click events coming from Mechane buttons.
func NewButtonClicks ¶
func NewButtonClicks() ButtonClicks
NewButtonClicks constructs a new ButtonClicks.
func (ButtonClicks) Extract ¶
func (seq ButtonClicks) Extract(fresh Collections, all Collections)
Extract the Mechane button click events from the given fresh collections.
Of the filtered click events, append those that pass temporal hysteresis checks to the receiver sequence in order from oldest to most recent.
The all collection shall contain and be a superset of the fresh collection.
type Collection ¶
type Collection struct { Events []Event // UI events ordered by time, that is from oldest to youngest. Shutterbug string // The target shutterbug of the UI events. }
A Collection of ordered UI events from one source.
func (Collection) Copy ¶
func (col Collection) Copy() Collection
Copy the collection.
The slice of events is independent but the events themselves are the same.
type Collections ¶
type Collections map[string]Collection
Collections is a snapshot of the UI events collected in a collector at a particular instant.
Map keys are UI event input sources.
func (Collections) ClearShutterbug ¶
func (cols Collections) ClearShutterbug(shutterbug string)
ClearShutterbug deletes the sources associated with the given shutterbug.
func (Collections) Fresh ¶
func (cols Collections) Fresh(old Collections) Collections
Fresh collected events present in the receiver collections which are not present in the argument older collections.
type Collector ¶
A Collector of UI events from various sources.
func NewCollector ¶
NewCollector constructs a new Collector.
func (*Collector) ClearShutterbug ¶
ClearShutterbug UI events for the given shutterbug and return the sources whose events were cleared.
func (*Collector) Close ¶
Close the collector disconnecting and deleting all current sources and rejecting any future attempts to add a new source.
func (*Collector) Collections ¶
func (clr *Collector) Collections() Collections
Collections of the collector.
Map keys are UI event input sources.
func (*Collector) RemoveShutterbug ¶
RemoveShutterbug from the collector and close the associated HTTP request handlers using that shutterbug.
The given reason is sent to clients as the close reason message.
func (*Collector) RemoveSource ¶
RemoveSource from the collector and close the associated HTTP request handler.
The given reason is sent to the client as the close reason message.
type Event ¶
type Event struct { E interface{} // The keyboard, mouse move, mouse button, and so on UI event. T time.Time // The UTC time of addition to the collection. }
An Event collected at a certain time.
type InOrderEvent ¶
type KeyboardEvent ¶
type KeyboardEvent struct { AltKey bool CtrlKey bool IsComposing bool Key string // https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key KeyDown bool // True for a key down event. MetaKey bool Pressed []string // All the pressed keyboard keys (logically not physically). Repeat bool ShiftKey bool }
A KeyboardEvent from a keyboard.
func (KeyboardEvent) Modified ¶
func (e KeyboardEvent) Modified() bool
Modified reports whether any modifier key was pressed when the event was created.
type MechaneButtonEvent ¶
type MechaneButtonEvent struct { AltKey bool Button float64 ClientX, ClientY float64 CtrlKey bool Detail int EffectName string MetaKey bool ShiftKey bool WindowW, WindowH float64 }
A MechaneButtonEvent from an overlay element.
func (MechaneButtonEvent) Modified ¶
func (e MechaneButtonEvent) Modified() bool
Modified reports whether any modifier key was pressed when the event was created.
type MechaneTextfieldKeyUpOrDownEvent ¶
type MechaneTextfieldKeyUpOrDownEvent struct { AltKey bool CtrlKey bool EffectName string IsComposing bool Key string // https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key KeyDown bool MetaKey bool ShiftKey bool Value string }
A MechaneTextfieldKeyUpOrDownEvent from an overlay element.
func (MechaneTextfieldKeyUpOrDownEvent) Modified ¶
func (e MechaneTextfieldKeyUpOrDownEvent) Modified() bool
Modified reports whether any modifier key was pressed when the event was created.
type MouseButtonEvent ¶
type MouseButtonEvent struct { AltKey bool Button float64 // https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/button ClientX, ClientY float64 // https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/clientX CtrlKey bool Detail int // https://developer.mozilla.org/en-US/docs/Web/API/UIEvent/detail MetaKey bool MouseDown bool ShiftKey bool WindowW, WindowH float64 // https://developer.mozilla.org/en-US/docs/Web/API/Window/innerHeight }
A MouseButtonEvent from a mouse is a mousedown or mouseup event.
func (MouseButtonEvent) Modified ¶
func (e MouseButtonEvent) Modified() bool
Modified reports whether any modifier key was pressed when the event was created.
type MouseMoveEvent ¶
type MouseMoveEvent struct { ActiveEditable bool // True if the hover is on a focused text editing area or similar. AltKey bool Buttons float64 // https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons ClientX, ClientY float64 // https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/clientX CtrlKey bool MetaKey bool MovementX, MovementY float64 // https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/movementX // The dynamic dimensions of the canvas element/view area, inclusive of // scaling, in units of pixels. PixelsW, PixelsH float64 PixelsOffsetX, PixelsOffsetY float64 // https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/offsetX PointerLock bool ShiftKey bool WindowW, WindowH float64 }
A MouseMoveEvent from a mouse.
func (MouseMoveEvent) Modified ¶
func (e MouseMoveEvent) Modified() bool
Modified reports whether any modifier key was pressed when the event was created.
type MouseWheelEvent ¶
type MouseWheelEvent struct { AltKey bool ClientX, ClientY float64 // https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/clientX CtrlKey bool DeltaX, DeltaY float64 // https://developer.mozilla.org/en-US/docs/Web/API/Element/wheel_event#event_properties EffectName string MetaKey bool ShiftKey bool WindowW, WindowH float64 }
A MouseWheelEvent from a mouse wheel.
https://developer.mozilla.org/en-US/docs/Web/API/Element/wheel_event
type TextfieldKeys ¶
type TextfieldKeys struct { *dryad.SyncAwaitSeq[InOrderEvent[MechaneTextfieldKeyUpOrDownEvent]] }
TextfieldKeys is a sequence of key events coming from Mechane textfields.
func NewTextfieldKeys ¶
func NewTextfieldKeys() TextfieldKeys
NewTextfieldKeys constructs a new TextfieldKeys.
func (TextfieldKeys) Extract ¶
func (seq TextfieldKeys) Extract(fresh Collections)
Extract the Mechane textfield key events from the given fresh collections and append them to the receiver sequence in order from oldest to most recent.
type WheelMoves ¶
type WheelMoves struct { *dryad.SyncAwaitSeq[InOrderEvent[MouseWheelEvent]] }
WheelMoves is a sequence of wheel move events.
func (WheelMoves) Extract ¶
func (seq WheelMoves) Extract(fresh Collections)
Extract the Mechane mouse wheel move events from the given fresh collections and append them to the receiver sequence in order from oldest to most recent.