mouse

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2022 License: BSD-3-Clause Imports: 8 Imported by: 12

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 = false

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_Actions = kit.Enums.AddEnum(ActionsN, kit.NotBitFlag, nil)
View Source
var KiT_Buttons = kit.Enums.AddEnum(ButtonsN, kit.NotBitFlag, nil)
View Source
var KiT_SelectModes = kit.Enums.AddEnum(SelectModesN, kit.NotBitFlag, nil)
View Source
var ScrollWheelSpeed = float32(20)

ScrollWheelSpeed controls how fast the scroll wheel moves (typically interpreted as pixels per wheel step) -- only relevant for some OS's which do not have a native preference for this setting, e.g., X11 This is also in gi.Prefs and updated from there

Functions

This section is empty.

Types

type Actions

type Actions int32

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

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

	ActionsN
)

func (*Actions) FromString

func (i *Actions) FromString(s string) error

func (Actions) String

func (i Actions) String() string

type Buttons

type Buttons int32

Buttons is a mouse button.

const (
	NoButton Buttons = iota
	Left
	Middle
	Right

	ButtonsN
)

func (*Buttons) FromString

func (i *Buttons) FromString(s string) error

func (Buttons) String

func (i Buttons) String() string

type DragEvent

type DragEvent struct {
	MoveEvent

	// Start is the initial location where the button was pressed
	// at the start of the Drag
	Start image.Point
}

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 Buttons

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

	// 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) HasAllModifier

func (e *Event) HasAllModifier(mods ...key.Modifiers) bool

HasAllModifiers tests whether all of given modifier(s) were set

func (*Event) HasAnyModifier

func (e *Event) HasAnyModifier(mods ...key.Modifiers) bool

HasAnyModifier tests whether any of given modifier(s) were set

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) SelectMode

func (e *Event) SelectMode() SelectModes

SelectMode returns the selection mode based on given modifiers on event

func (*Event) SetModifiers

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

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

func (*Event) String

func (ev *Event) String() string

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 HoverEvent

type HoverEvent struct {
	Event
}

mouse.HoverEvent is generated by gi.Window based on lack of motion after entering a widget

func (*HoverEvent) Type

func (ev *HoverEvent) 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

type SelectModes

type SelectModes int32

SelectModes interprets the modifier keys to determine what type of selection mode to use This is also used for selection actions and has modes not directly activated by modifier keys

const (
	// SelectOne selects a single item, and is the default when no modifier key
	// is pressed
	SelectOne SelectModes = iota

	// ExtendContinuous, activated by Shift key, extends the selection to
	// select a continuous region of selected items, with no gaps
	ExtendContinuous

	// ExtendOne, activated by Control or Meta / Command, extends the
	// selection by adding the one additional item just clicked on, creating a
	// potentially discontinuous set of selected items
	ExtendOne

	// NoSelect means do not update selection -- this is used programmatically
	// and not available via modifier key
	NoSelect

	// Unselect means unselect items -- this is used programmatically
	// and not available via modifier key -- typically ExtendOne will
	// unselect if already selected
	Unselect

	// SelectQuiet means select without doing other updates or signals -- for
	// bulk updates with a final update at the end -- used programmatically
	SelectQuiet

	// UnselectQuiet means unselect without doing other updates or signals -- for
	// bulk updates with a final update at the end -- used programmatically
	UnselectQuiet

	SelectModesN
)

func SelectModeBits

func SelectModeBits(modBits int32) SelectModes

SelectModeBits returns the selection mode based on given modifiers bitflags

func (*SelectModes) FromString

func (i *SelectModes) FromString(s string) error

func (SelectModes) String

func (i SelectModes) String() string

Jump to

Keyboard shortcuts

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