mouse package - github.com/oakmound/oak/v4/mouse - Go Packages
Package mouse handles the propagation of mouse events though clickable regions. It extends the functionality of the collision package.
- Constants
- Variables
- func Add(sps ...*collision.Space)
- func Clear()
- func EventOn(ev event.EventID[*Event]) (event.EventID[*Event], bool)
- func EventRelative(ev event.EventID[*Event]) (event.EventID[*Event], bool)
- func GetEvent(d mouse.Direction, b mouse.Button) event.EventID[*Event]
- func HitLabel(sp *collision.Space, labels ...collision.Label) *collision.Space
- func Hits(sp *collision.Space) []*collision.Space
- func PhaseCollision(s *collision.Space, handler event.Handler) error
- 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 Button
- type CollisionPhase
- type Event
Min and Max Z layer inform what range of z layer values will be checked on mouse collision interactions. Mouse events will not propagate to elements with z layers outside of this range.
Valid Button event types
MouseCollisionStart/Stop: see collision Start/Stop, for mouse collision
DefaultTree is a collision tree intended to be used by default if no other is instantiated. Methods on a collision tree are duplicated as functions in this package, so `tree.Add(...)` can instead be `mouse.Add(...)` if the codebase is coordinated to just use the default tree.
Add adds a set of spaces to the rtree
Clear resets the default collision tree
EventOn converts a generic positioned mouse event into its variant indicating it occurred on a CallerID targetted entity
GetEventName returns a string event name given some mobile/mouse information
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.
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.
Remove removes a space from the rtree
ShiftSpace adds x and y to a space and updates its position in the collision rtree that should not be a package global
UpdateSpace resets a space's location to a given rtreego.Rect. This is not an operation on a space because a space can exist in multiple rtrees.
Button represents a mouse interaction type, like a left button or mouse wheel movement.
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 an event.
ToSpace converts a mouse event into a collision space