mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-01 07:35:40 +00:00
io/pointer,gesture: report right and middle mouse button events
Updates gio#60 Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
@@ -5,6 +5,7 @@ package pointer
|
||||
import (
|
||||
"encoding/binary"
|
||||
"image"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"gioui.org/f32"
|
||||
@@ -27,6 +28,8 @@ type Event struct {
|
||||
// Time is when the event was received. The
|
||||
// timestamp is relative to an undefined base.
|
||||
Time time.Duration
|
||||
// Buttons are the set of pressed mouse buttons for this event.
|
||||
Buttons Buttons
|
||||
// Hit is set when the event was within the registered
|
||||
// area for the handler. Hit can be false when a pointer
|
||||
// was pressed within the hit area, and then dragged
|
||||
@@ -86,6 +89,9 @@ type Priority uint8
|
||||
// Source of an Event.
|
||||
type Source uint8
|
||||
|
||||
// Buttons is a set of mouse buttons
|
||||
type Buttons uint8
|
||||
|
||||
// Must match app/internal/input.areaKind
|
||||
type areaKind uint8
|
||||
|
||||
@@ -116,6 +122,12 @@ const (
|
||||
Grabbed
|
||||
)
|
||||
|
||||
const (
|
||||
ButtonLeft Buttons = 1 << iota
|
||||
ButtonRight
|
||||
ButtonMiddle
|
||||
)
|
||||
|
||||
const (
|
||||
areaRect areaKind = iota
|
||||
areaEllipse
|
||||
@@ -199,4 +211,24 @@ func (s Source) String() string {
|
||||
}
|
||||
}
|
||||
|
||||
// Contain reports whether the set b contains
|
||||
// all of the buttons.
|
||||
func (b Buttons) Contain(buttons Buttons) bool {
|
||||
return b&buttons == buttons
|
||||
}
|
||||
|
||||
func (b Buttons) String() string {
|
||||
var strs []string
|
||||
if b.Contain(ButtonLeft) {
|
||||
strs = append(strs, "ButtonLeft")
|
||||
}
|
||||
if b.Contain(ButtonRight) {
|
||||
strs = append(strs, "ButtonRight")
|
||||
}
|
||||
if b.Contain(ButtonMiddle) {
|
||||
strs = append(strs, "ButtonMiddle")
|
||||
}
|
||||
return strings.Join(strs, "|")
|
||||
}
|
||||
|
||||
func (Event) ImplementsEvent() {}
|
||||
|
||||
Reference in New Issue
Block a user