interaction

package
v0.0.0-...-23eb0d9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 10, 2020 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package interaction handles the user interaction with mouse and keyboard.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CursorPosHandler

type CursorPosHandler func(float64, float64, float64, float64) bool

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
	OnResize(width, height 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

New 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) AddResizeHandler

func (interaction *Interaction) AddResizeHandler(handler ResizeHandler)

AddResizeHandler registers a ResizeHandler 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

type KeyPressHandler func(int, int, int) bool

KeyPressHandler is called every time a keyboard key is pressed or released.

type MouseButtonHandler

type MouseButtonHandler func(bool, bool) bool

MouseButtonHandler is called every time the left or right mouse button is pressed or released.

type MouseScrollHandler

type MouseScrollHandler func(float64, float64) bool

MouseScrollHandler is called every time the mouse scroll is used.

type ResizeHandler

type ResizeHandler func(int, int) bool

ResizeHandler is called every time the window is resized.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL