mouse

package
v0.0.0-...-5f41422 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2018 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Overview

Package mouse defines mouse events, for the GoGi GUI system. The most important distinction for mouse events is moving versus static -- many GI elements don't need to know about motion, and they are high-volume events, so it is important to split those out.

Index

Constants

This section is empty.

Variables

View Source
var DoubleClickMSec = 500

DoubleClickMSec is the maximum time interval in msec between button press events to count as a double-click -- can set this global variable to change. This is also in gi.Prefs and updated from there

View Source
var DoubleClickWait = true

DoubleClickWait causes the event system to wait for a possible double-click event before sending single clicks. This causes a delay, but avoids many sources of potential difficulty in dealing with double-clicking, as described here: https://blogs.msdn.microsoft.com/oldnewthing/20041015-00/?p=37553

View Source
var KiT_Action = kit.Enums.AddEnum(ActionN, false, nil)
View Source
var KiT_Button = kit.Enums.AddEnum(ButtonN, false, nil)

Functions

This section is empty.

Types

type Action

type Action int32

Action taken with the mouse button -- different ones are applicable to different mouse event types

const (
	NoAction Action = iota
	Press
	Release
	DoubleClick
	Move
	Drag
	Scroll
	Enter
	Exit

	ActionN
)

func StringToAction

func StringToAction(s string) (Action, error)

func (Action) String

func (i Action) String() string

type Button

type Button int32

Button is a mouse button.

const (
	NoButton Button = iota
	Left
	Middle
	Right

	ButtonN
)

func StringToButton

func StringToButton(s string) (Button, error)

func (Button) String

func (i Button) String() string

type DragEvent

type DragEvent struct {
	MoveEvent
}

mouse.DragEvent is for mouse movement, with button down -- action is Drag -- many receivers will be interested in Drag events but not Move events, which is why these are separate

func (DragEvent) Type

func (ev DragEvent) Type() oswin.EventType

type Event

type Event struct {
	oswin.EventBase

	// Where is the mouse location, in raw display dots (raw, actual pixels)
	Where image.Point

	// Button is the mouse button being pressed or released. Its value may be
	// ButtonNone (zero), for a mouse move with no button
	Button Button

	// Action taken on the mouse button: Press, Release, DoubleClick, Drag or Move
	Action Action

	// Modifiers is a bitmask representing a set of modifier keys:
	// key.ModShift, key.ModAlt, etc. -- bit positions are key.Modifiers
	Modifiers int32
}

mouse.Event is a basic mouse event for button presses, but not motion or scrolling

func (Event) HasPos

func (ev Event) HasPos() bool

func (Event) OnFocus

func (ev Event) OnFocus() bool

func (Event) Pos

func (ev Event) Pos() image.Point

func (*Event) SetModifiers

func (e *Event) SetModifiers(mods ...key.Modifiers)

SetModifiers sets the bitflags based on a list of key.Modifiers

func (Event) Type

func (ev Event) Type() oswin.EventType

type FocusEvent

type FocusEvent struct {
	Event
}

mouse.FocusEvent records actions of Enter and Exit of mouse into a given widget bounding box -- generated from mouse.MoveEvents in gi.Window, which knows about widget bounding boxes

func (FocusEvent) Type

func (ev FocusEvent) Type() oswin.EventType

type MoveEvent

type MoveEvent struct {
	Event

	// From is the previous location of the mouse
	From image.Point

	// LastTime is the time of the previous event
	LastTime time.Time
}

mouse.MoveEvent is for mouse movement, without button down -- action is Move

func (MoveEvent) Delta

func (e MoveEvent) Delta() image.Point

Delta returns the amount of mouse movement (Where - From)

func (MoveEvent) Type

func (ev MoveEvent) Type() oswin.EventType

type ScrollEvent

type ScrollEvent struct {
	Event

	// Delta is the amount of scrolling in each axis
	Delta image.Point
}

mouse.ScrollEvent is for mouse scrolling, recording the delta of the scroll

func (ScrollEvent) NonZeroDelta

func (e ScrollEvent) NonZeroDelta(prefX bool) int

NonZeroDelta attempts to find a non-zero delta -- often only get Y dimension scrolling and want to use that for X if prefX is true

func (ScrollEvent) Type

func (ev ScrollEvent) Type() oswin.EventType

Jump to

Keyboard shortcuts

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