Debian Codegraph @

event/mouse/mouse.go

raw symbols SCIP
1 // Copyright 2015 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 // Package mouse defines an event for mouse input.
6 //
7 // See the golang.org/x/mobile/app package for details on the event model.
8 package mousescip-go gomod golang.org/x/mobile . `golang.org/x/mobile/event/mouse`/
9
10 import (
11 "fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/"
12
13 "golang.org/x/mobile/event/keyscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/event/key`/"
14 )
15
16 // Event is a mouse event.
17 type Eventscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/event/mouse`/Event# struct {
18 // X and Y are the mouse location, in pixels.
19 Xscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/event/mouse`/Event#X., Yscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/event/mouse`/Event#Y. float32
20
21 // Button is the mouse button being pressed or released. Its value may be
22 // zero, for a mouse move or drag without any button change.
23 Buttonscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/event/mouse`/Event#Button. Buttonscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/event/mouse`/Button#
24
25 // TODO: have a field to hold what other buttons are down, for detecting
26 // drags or button-chords.
27
28 // Modifiers is a bitmask representing a set of modifier keys:
29 // key.ModShift, key.ModAlt, etc.
30 Modifiersscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/event/mouse`/Event#Modifiers. keyscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/event/key`/.Modifiersscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/event/key`/Modifiers#
31
32 // Direction is the direction of the mouse event: DirPress, DirRelease,
33 // or DirNone (for mouse moves or drags).
34 Directionscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/event/mouse`/Event#Direction. Directionscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/event/mouse`/Direction#
35
36 // TODO: add a Device ID, for multiple input devices?
37 // TODO: add a time.Time?
38 }
39
40 // Button is a mouse button.
41 type Buttonscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/event/mouse`/Button# int32
42
43 // IsWheel reports whether the button is for a scroll wheel.
44 func (b Buttonscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/event/mouse`/Button#) IsWheelscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/event/mouse`/Button#IsWheel().() bool {
45 return b < 0
46 }
47
48 // TODO: have a separate axis concept for wheel up/down? How does that relate
49 // to joystick events?
50
51 const (
52 ButtonNonescip-go gomod golang.org/x/mobile . `golang.org/x/mobile/event/mouse`/ButtonNone. Buttonscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/event/mouse`/Button# = +0
53 ButtonLeftscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/event/mouse`/ButtonLeft. Buttonscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/event/mouse`/Button# = +1
54 ButtonMiddlescip-go gomod golang.org/x/mobile . `golang.org/x/mobile/event/mouse`/ButtonMiddle. Buttonscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/event/mouse`/Button# = +2
55 ButtonRightscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/event/mouse`/ButtonRight. Buttonscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/event/mouse`/Button# = +3
56
57 ButtonWheelUpscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/event/mouse`/ButtonWheelUp. Buttonscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/event/mouse`/Button# = -1
58 ButtonWheelDownscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/event/mouse`/ButtonWheelDown. Buttonscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/event/mouse`/Button# = -2
59 ButtonWheelLeftscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/event/mouse`/ButtonWheelLeft. Buttonscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/event/mouse`/Button# = -3
60 ButtonWheelRightscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/event/mouse`/ButtonWheelRight. Buttonscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/event/mouse`/Button# = -4
61 )
62
63 // Direction is the direction of the mouse event.
64 type Directionscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/event/mouse`/Direction# uint8
65
66 const (
67 DirNonescip-go gomod golang.org/x/mobile . `golang.org/x/mobile/event/mouse`/DirNone. Directionscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/event/mouse`/Direction# = 0
68 DirPressscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/event/mouse`/DirPress. Directionscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/event/mouse`/Direction# = 1
69 DirReleasescip-go gomod golang.org/x/mobile . `golang.org/x/mobile/event/mouse`/DirRelease. Directionscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/event/mouse`/Direction# = 2
70 // DirStep is a simultaneous press and release, such as a single step of a
71 // mouse wheel.
72 //
73 // Its value equals DirPress | DirRelease.
74 DirStepscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/event/mouse`/DirStep. Directionscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/event/mouse`/Direction# = 3
75 )
76
77 func (d Directionscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/event/mouse`/Direction#) Stringscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/event/mouse`/Direction#String().() string {
78 switch d {
79 case DirNonescip-go gomod golang.org/x/mobile . `golang.org/x/mobile/event/mouse`/DirNone.:
80 return "None"
81 case DirPressscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/event/mouse`/DirPress.:
82 return "Press"
83 case DirReleasescip-go gomod golang.org/x/mobile . `golang.org/x/mobile/event/mouse`/DirRelease.:
84 return "Release"
85 case DirStepscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/event/mouse`/DirStep.:
86 return "Step"
87 default:
88 return fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Sprintf().("mouse.Direction(%d)", d)
89 }
90 }