From 204c03cc808cc260f1313ef9c5d415db58d70ab9 Mon Sep 17 00:00:00 2001 From: Nigel Tao Date: Fri, 1 Jul 2016 13:33:03 +1000 Subject: [PATCH] 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 --- event/mouse/mouse.go | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/event/mouse/mouse.go b/event/mouse/mouse.go index 7875c64..45029cc 100644 --- a/event/mouse/mouse.go +++ b/event/mouse/mouse.go @@ -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.