Documentation ¶
Overview ¶
Package mouse implements various mouse related data types.
Index ¶
- Constants
- type Button
- type ButtonEvent
- type Scrolled
- type State
- type Watcher
- func (w *Watcher) Down(button Button) bool
- func (w *Watcher) EachState(f func(b Button, s State) bool)
- func (w *Watcher) SetState(button Button, state State)
- func (w *Watcher) State(button Button) State
- func (w *Watcher) States() []State
- func (w *Watcher) String() string
- func (w *Watcher) Up(button Button) bool
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).
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Button ¶
type Button uint8
Button represents a single mouse button.
Mouse button constants for buttons one through eight. The Invalid button is declared to help users detect uninitialized variables.
type ButtonEvent ¶
ButtonEvent represents an single mouse button event.
func (ButtonEvent) String ¶
func (b ButtonEvent) String() string
String returns an string representation of this event.
func (ButtonEvent) Time ¶
func (b ButtonEvent) Time() time.Time
Time returns the time at which this event occured.
type Scrolled ¶
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.
type State ¶
type State uint8
State represents a single mouse state, such as Up or Down.
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.
type Watcher ¶
type Watcher struct {
// contains filtered or unexported fields
}
Watcher watches the state of various mouse buttons and their states.
func (*Watcher) Down ¶
Down tells whether the specified mouse button is currently in the down state.
func (*Watcher) EachState ¶
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) States ¶
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.