event/mouse: add Button.IsWheel, ButtonWheelLeft and ButtonWheelRight.

Horizontal wheel events can come from some tilting scroll wheels, as
well as trackpoints (pointing sticks).

Change-Id: I02be43d44a65123e2d58539e291e9e6ac7e6bff4
Reviewed-on: https://go-review.googlesource.com/24633
Reviewed-by: David Crawshaw <crawshaw@golang.org>
This commit is contained in:
Nigel Tao 2016-07-01 13:33:03 +10:00
parent 2d0a4d3322
commit 204c03cc80
1 changed files with 14 additions and 6 deletions

View File

@ -40,16 +40,24 @@ type Event struct {
// Button is a mouse button.
type Button int32
// IsWheel returns whether the button is for a scroll wheel.
func (b Button) IsWheel() bool {
return b < 0
}
// TODO: have a separate axis concept for wheel up/down? How does that relate
// to joystick events?
const (
ButtonNone Button = +0
ButtonLeft Button = +1
ButtonMiddle Button = +2
ButtonRight Button = +3
ButtonWheelUp Button = -1
ButtonWheelDown Button = -2
ButtonNone Button = +0
ButtonLeft Button = +1
ButtonMiddle Button = +2
ButtonRight Button = +3
ButtonWheelUp Button = -1
ButtonWheelDown Button = -2
ButtonWheelLeft Button = -3
ButtonWheelRight Button = -4
)
// Direction is the direction of the mouse event.