Package mouse handles the propagation of mouse events though clickable regions. It extends the functionality of the collision package.
- func Add(sps ...*collision.Space)
- func Clear()
- func GetEventName(d mouse.Direction, b mouse.Button) string
- func GetMouseButton(b mouse.Button) (s string)
- func HitLabel(sp *collision.Space, labels ...collision.Label) *collision.Space
- func Hits(sp *collision.Space) *collision.Space
- func PhaseCollision(s *collision.Space) error
- func Propagate(eventName string, me Event)
- func Remove(sps ...*collision.Space)
- func ShiftSpace(x, y float64, s *collision.Space) error
- func UpdateSpace(x, y, w, h float64, s *collision.Space) error
- type CollisionPhase
- type Event
- type GestureEvent
const ( Start = "MouseCollisionStart" Stop = "MouseCollisionStop" )
MouseCollisionStart/Stop: see collision Start/Stop, for mouse collision Payload: (mouse.Event)
const ( Press = "MousePress" Release = "MouseRelease" ScrollDown = "MouseScrollDown" ScrollUp = "MouseScrollUp" Click = "MouseClick" Drag = "MouseDrag" // PressOn = Press + "On" ReleaseOn = Release + "On" ScrollDownOn = ScrollDown + "On" ScrollUpOn = ScrollUp + "On" ClickOn = Click + "On" DragOn = Drag + "On" )
Mouse events: MousePress, MouseRelease, MouseScrollDown, MouseScrollUp, MouseDrag Payload: (mouse.Event) details of the mouse event
var ( // LastEvent is the last triggered mouse event, // tracked for continuous mouse responsiveness on events // that don't take in a mouse event LastEvent = NewZeroEvent(0, 0) // LastPress is the last triggered mouse event, // where the mouse event was a press. // If TrackMouseClicks is set to false then this will not be tracked LastPress = NewZeroEvent(0, 0) )
There's a default collision tree you can access via collision.func as opposed to tree.func
func GetEventName ¶ added in v1.4.0
GetEventName returns a string event name given some mobile/mouse information
func GetMouseButton ¶
GetMouseButton is a utitilty function which translates integer values of mouse keys from golang's event/mouse library into strings. Intended for internal use.
HitLabel acts like hits, but reutrns the first space within hits that matches one of the input labels
Hits returns the set of spaces which are colliding with the passed in space.
func PhaseCollision ¶
PhaseCollision binds to the entity behind the space's CID so that it will receive MouseCollisionStart and MouseCollisionStop events, appropriately when the mouse begins to hover or stops hovering over the input space.
Propagate triggers direct mouse events on entities which are clicked
func ShiftSpace ¶
ShiftSpace adds x and y to a space and updates its position in the collision rtree that should not be a package global
type CollisionPhase ¶
CollisionPhase is a component that can be placed into another struct to enable PhaseCollision on the struct. See PhaseCollision.
An Event is passed in through all Mouse related event bindings to indicate what type of mouse event was triggered, where it was triggered, and which mouse button it concerns.
NewEvent creates and returns an Event
func NewZeroEvent ¶
NewZeroEvent creates an event with no button or event string.
type GestureEvent ¶
A GestureEvent is a conversion of a shiny Gesture to our local type so we don't need to import shiny variables in more places. GestureEvents contain information about mouse events that are not single actions, like drags, holds, and double clicks. Todo: standardize events to also use vectors for their position