Documentation ¶
Index ¶
- Variables
- func ClickListener(handler func(ClickEvent)) (events.Type, events.Handler)
- func EventListener(handler func(Event)) (events.Type, events.Handler)
- func PressListener(handler func(Event)) (events.Type, events.Handler)
- func ScrollListener(handler func(ev ScrollEvent)) (events.Type, events.Handler)
- func UpListener(handler func(Event)) (events.Type, events.Handler)
- type ButtonMask
- type ClickEvent
- type Event
- type ScrollDirection
- type ScrollEvent
Constants ¶
This section is empty.
Variables ¶
var ClickEventType = events.NewType("Click")
var MouseEventType = events.NewType("Mouse")
var PressEventType = events.NewType("MousePress")
var ScrollEventType = events.NewType("Scroll")
var UpEventType = events.NewType("MouseUp")
Functions ¶
func ClickListener ¶
func ClickListener(handler func(ClickEvent)) (events.Type, events.Handler)
ClickListener returns an events.Listener that will call the given handler on click events.
func EventListener ¶
EventListener returns an events.Listener that will call the given handler on mouse events.
func PressListener ¶
PressListener returns an events.Listener that will call the given handler on mouse press events.
func ScrollListener ¶
func ScrollListener(handler func(ev ScrollEvent)) (events.Type, events.Handler)
Types ¶
type ButtonMask ¶
type ButtonMask int16
ButtonMask is a mask of mouse buttons and wheel events. Mouse button presses are normally delivered as both press and release events. Mouse wheel events are normally just single impulse events. Windows supports up to eight separate buttons, but XTerm can only support mouse buttons 1-3. Its not unheard of for terminals to support only one or two buttons (think Macs). Old terminals, and true emulations (such as vt100) won't support mice at all, of course.
const ( Button1 ButtonMask = 1 << iota // Usually the left (primary) mouse button. Button2 // Usually the right (secondary) mouse button. Button3 // Usually the middle mouse button. Button4 // Often a side button (thumb/next). Button5 // Often a side button (thumb/prev). Button6 Button7 Button8 ButtonNone ButtonMask = 0 // No button. ButtonPrimary = Button1 ButtonSecondary = Button2 ButtonMiddle = Button3 )
These are the actual button values. Note that tcell version 1.x reversed buttons two and three on *nix based terminals. We use button 1 as the primary, and button 2 as the secondary, and button 3 (which is often missing) as the middle.
type ClickEvent ¶
ClickEvent define an event triggered by a primary mouse click, that is a mouse press followed by a mouse up (positions can differ). Unlike mouse up event, click events is dispatched to target at mouse press position.
func NewClick ¶
func NewClick(pos geometry.Vec2D, buttons ButtonMask, mods keypress.ModMask, mousePress Event) ClickEvent
NewClick returns a new click event.
type Event ¶
type Event struct { events.Event // Mouse absolute position. AbsPosition geometry.Vec2D // Position relative to element position. RelPosition geometry.Vec2D // List of buttons that were pressed. Buttons ButtonMask // Modifiers is the modifiers that were present with the key press. Note // that not all platforms and terminals support this equally well, and some // cases we will not not know for sure. Hence, applications should avoid // using this in most circumstances. Modifiers keypress.ModMask }
Event is a generic mouse event. A mouse event can be of events.Type:
* MousePress
* MouseUp
type ScrollDirection ¶
type ScrollDirection int8
const ( ScrollUp ScrollDirection = iota ScrollDown ScrollLeft ScrollRight )
type ScrollEvent ¶
type ScrollEvent struct { Event ScrollDirection }
ScrollEvent is a mouse event triggered on mouse scroll. It supports horizontal and vertical scroll.
func NewScroll ¶
func NewScroll(pos geometry.Vec2D, modifiers keypress.ModMask, direction ScrollDirection) ScrollEvent
func (ScrollEvent) Horizontal ¶
func (se ScrollEvent) Horizontal() bool
func (ScrollEvent) Vertical ¶
func (se ScrollEvent) Vertical() bool