Documentation ¶
Overview ¶
Package interaction handles the user interaction with mouse and keyboard.
Index ¶
- type CursorPosHandler
- type Interactable
- type Interaction
- func (interaction *Interaction) AddCursorPosHandler(handler CursorPosHandler)
- func (interaction *Interaction) AddInteractable(interactable Interactable)
- func (interaction *Interaction) AddKeyPressHandler(handler KeyPressHandler)
- func (interaction *Interaction) AddMouseButtonHandler(handler MouseButtonHandler)
- func (interaction *Interaction) AddMouseScrollHandler(handler MouseScrollHandler)
- func (interaction *Interaction) EnableCursorLoop()
- type KeyPressHandler
- type MouseButtonHandler
- type MouseScrollHandler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CursorPosHandler ¶
CursorPosHandler is called every time the cursor position changes.
type Interactable ¶
type Interactable interface { OnCursorPosMove(x, y, dx, dy float64) bool OnMouseButtonPress(leftPressed, rightPressed bool) bool OnMouseScroll(x, y float64) bool OnKeyPress(key, action, mods int) bool }
Interactable is an entity that listens to different events and reacts to them.
type Interaction ¶
type Interaction struct {
// contains filtered or unexported fields
}
Interaction holds all eventhandlers and propagates them to it's registered handlers.
func New ¶
func New(window *window.Window) *Interaction
Make constructs an Interaction and registers all necessary handlers for the window.
func (*Interaction) AddCursorPosHandler ¶
func (interaction *Interaction) AddCursorPosHandler(handler CursorPosHandler)
AddCursorPosHandler registers a CursorPosHandler in the Window.
func (*Interaction) AddInteractable ¶
func (interaction *Interaction) AddInteractable(interactable Interactable)
AddInteractable registers all handlers of the interactable in the Windowmanager.
func (*Interaction) AddKeyPressHandler ¶
func (interaction *Interaction) AddKeyPressHandler(handler KeyPressHandler)
AddKeyPressHandler registers a KeyPressHandler in the Window.
func (*Interaction) AddMouseButtonHandler ¶
func (interaction *Interaction) AddMouseButtonHandler(handler MouseButtonHandler)
AddMouseButtonHandler registers a MouseButtonHandler in the Window.
func (*Interaction) AddMouseScrollHandler ¶
func (interaction *Interaction) AddMouseScrollHandler(handler MouseScrollHandler)
AddMouseScrollHandler registers a MouseScrollHandler in the Window.
func (*Interaction) EnableCursorLoop ¶
func (interaction *Interaction) EnableCursorLoop()
EnableCursorLoop hides the cursor and loops it inside the window in x and y direction.
type KeyPressHandler ¶
KeyPressHandler is called every time a keyboard key is pressed or released.
type MouseButtonHandler ¶
MouseButtonHandler is called every time the left or right mouse button is pressed or released.
type MouseScrollHandler ¶
MouseScrollHandler is called every time the mouse scroll is used.