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 ¶
- Variables
- type Actions
- type Buttons
- type DragEvent
- type Event
- func (e *Event) HasAllModifier(mods ...key.Modifiers) bool
- func (e *Event) HasAnyModifier(mods ...key.Modifiers) bool
- func (ev *Event) HasPos() bool
- func (ev *Event) OnFocus() bool
- func (ev *Event) Pos() image.Point
- func (e *Event) SelectMode() SelectModes
- func (e *Event) SetModifiers(mods ...key.Modifiers)
- func (ev *Event) String() string
- func (ev *Event) Type() oswin.EventType
- type FocusEvent
- type HoverEvent
- type MoveEvent
- type ScrollEvent
- type SelectModes
Constants ¶
This section is empty.
Variables ¶
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
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
var KiT_Actions = kit.Enums.AddEnum(ActionsN, kit.NotBitFlag, nil)
var KiT_Buttons = kit.Enums.AddEnum(ButtonsN, kit.NotBitFlag, nil)
var KiT_SelectModes = kit.Enums.AddEnum(SelectModesN, kit.NotBitFlag, nil)
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
func (*Actions) FromString ¶
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.
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 ¶
HasAllModifiers tests whether all of given modifier(s) were set
func (*Event) HasAnyModifier ¶
HasAnyModifier tests whether any of given modifier(s) were set
func (*Event) SelectMode ¶
func (e *Event) SelectMode() SelectModes
SelectMode returns the selection mode based on given modifiers on event
func (*Event) SetModifiers ¶
SetModifiers sets the bitflags based on a list of key.Modifiers
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
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