mirror of https://github.com/gdamore/tcell.git
fixes #358 EventMouse button mapping
This commit is contained in:
parent
fcaa20f283
commit
5bef26acc2
16
mouse.go
16
mouse.go
|
@ -1,4 +1,4 @@
|
|||
// Copyright 2015 The TCell Authors
|
||||
// Copyright 2020 The TCell Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use file except in compliance with the License.
|
||||
|
@ -79,11 +79,13 @@ func NewEventMouse(x, y int, btn ButtonMask, mod ModMask) *EventMouse {
|
|||
// emulations (such as vt100) won't support mice at all, of course.
|
||||
type ButtonMask int16
|
||||
|
||||
// These are the actual button values.
|
||||
// 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.
|
||||
const (
|
||||
Button1 ButtonMask = 1 << iota // Usually left mouse button.
|
||||
Button2 // Usually the middle mouse button.
|
||||
Button3 // Usually the right mouse button.
|
||||
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
|
||||
|
@ -94,4 +96,8 @@ const (
|
|||
WheelLeft // Wheel motion to left.
|
||||
WheelRight // Wheel motion to right.
|
||||
ButtonNone ButtonMask = 0 // No button or wheel events.
|
||||
|
||||
ButtonPrimary = Button1
|
||||
ButtonSecondary = Button2
|
||||
ButtonMiddle = Button3
|
||||
)
|
||||
|
|
|
@ -919,10 +919,10 @@ func (t *tScreen) buildMouseEvent(x, y, btn int) *EventMouse {
|
|||
button = Button1
|
||||
t.wasbtn = true
|
||||
case 1:
|
||||
button = Button2
|
||||
button = Button3 // Note we prefer to treat right as button 2
|
||||
t.wasbtn = true
|
||||
case 2:
|
||||
button = Button3
|
||||
button = Button2 // And the middle button as button 3
|
||||
t.wasbtn = true
|
||||
case 3:
|
||||
button = ButtonNone
|
||||
|
|
Loading…
Reference in New Issue