Documentation ¶
Overview ¶
Package mouse handles the propagation of mouse events though clickable regions. It extends the functionality of the collision package.
Index ¶
- Constants
- Variables
- 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
Constants ¶
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
Variables ¶
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) )
var (
DefTree *collision.Tree
)
There's a default collision tree you can access via collision.func as opposed to tree.func
var ( //TrackMouseClicks enables the propagation of MouseClickOn during MouseRelease events TrackMouseClicks = true )
Functions ¶
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.
func HitLabel ¶
HitLabel acts like hits, but reutrns the first space within hits that matches one of the input labels
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.
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
Types ¶
type CollisionPhase ¶
type CollisionPhase struct { OnCollisionS *collision.Space // contains filtered or unexported fields }
CollisionPhase is a component that can be placed into another struct to enable PhaseCollision on the struct. See PhaseCollision.
type Event ¶
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.
func NewZeroEvent ¶
NewZeroEvent creates an event with no button or event string.
type GestureEvent ¶
type GestureEvent struct { Drag bool LongPress bool DoublePress bool InitialPos physics.Vector CurrentPos physics.Vector Time time.Time }
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
func FromShinyGesture ¶
func FromShinyGesture(shinyGesture gesture.Event) GestureEvent
FromShinyGesture converts a shiny gesture.Event to a GestureEvent