engine: azul3d.org/engine/mouse Index | Files

package mouse

import "azul3d.org/engine/mouse"

Package mouse implements various mouse related data types.

Index

Package Files

doc.go events.go mouse.go stringers.go watcher.go

Constants

const (
    Left   = One
    Right  = Two
    Wheel  = Three
    Middle = Three
)

Left, Right, Middle and Wheel are simply aliases. Their true names are mouse button One, Two, and Three (for both Middle and Wheel, respectively).

type Button Uses

type Button uint8

Button represents a single mouse button.

const (
    Invalid Button = iota
    One
    Two
    Three
    Four
    Five
    Six
    Seven
    Eight
)

Mouse button constants for buttons one through eight. The Invalid button is declared to help users detect uninitialized variables.

func (Button) String Uses

func (i Button) String() string

type ButtonEvent Uses

type ButtonEvent struct {
    T      time.Time
    Button Button
    State  State
}

ButtonEvent represents an single mouse button event.

func (ButtonEvent) String Uses

func (b ButtonEvent) String() string

String returns an string representation of this event.

func (ButtonEvent) Time Uses

func (b ButtonEvent) Time() time.Time

Time returns the time at which this event occured.

type Scrolled Uses

type Scrolled struct {
    T   time.Time

    // Amount of scrolling in horizontal (X) and vertical (Y) directions.
    X, Y float64
}

Scrolled is an event where the user has scrolled their mouse wheel.

func (Scrolled) String Uses

func (s Scrolled) String() string

String returns a string representation of this event.

func (Scrolled) Time Uses

func (s Scrolled) Time() time.Time

Time implements the Event interface.

type State Uses

type State uint8

State represents a single mouse state, such as Up or Down.

const (
    InvalidState State = iota
    Down
    Up
)

Mouse button state constants, Down implies the button is currently pressed down, and up implies it is not. The InvalidState is declared to help users detect uninitialized variables.

func (State) String Uses

func (i State) String() string

type Watcher Uses

type Watcher struct {
    // contains filtered or unexported fields
}

Watcher watches the state of various mouse buttons and their states.

func NewWatcher Uses

func NewWatcher() *Watcher

NewWatcher returns a new, initialized, mouse watcher.

func (*Watcher) Down Uses

func (w *Watcher) Down(button Button) bool

Down tells whether the specified mouse button is currently in the down state.

func (*Watcher) EachState Uses

func (w *Watcher) EachState(f func(b Button, s State) bool)

EachState calls f with each known button to this watcher and it's current button state. It does so until the function returns false or there are no more buttons known to the watcher.

func (*Watcher) SetState Uses

func (w *Watcher) SetState(button Button, state State)

SetState specifies the current state of the specified mouse button.

func (*Watcher) State Uses

func (w *Watcher) State(button Button) State

State returns the current state of the specified mouse button.

func (*Watcher) States Uses

func (w *Watcher) States() []State

States returns an copy of the internal mouse button state lookup table used by this watcher. The indices of the lookup table are literally Button values:

states := watcher.States()
leftState := states[mouse.Left]
if leftState != InvalidState {
    fmt.Println("The left mouse button state is", leftState)
}

States for buttons not known to the watcher are equal to InvalidState.

At max the lookup table will be of length 256 (as Button is declared as a uint8), but it may be less.

func (*Watcher) String Uses

func (w *Watcher) String() string

String returns a multi-line string representation of this mouse watcher and it's associated states.

func (*Watcher) Up Uses

func (w *Watcher) Up(button Button) bool

Up tells whether the specified mouse button is currently in the up state.

Package mouse imports 4 packages (graph) and is imported by 7 packages. Updated 2016-07-18. Refresh now. Tools for package owners.