Debian Codegraph @

event/touch/touch.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 touch defines an event for touch input.
6 //
7 // See the golang.org/x/mobile/app package for details on the event model.
8 package touchscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/event/touch`/
9
10 // The best source on android input events is the NDK: include/android/input.h
11 //
12 // iOS event handling guide:
13 // https://developer.apple.com/library/ios/documentation/EventHandling/Conceptual/EventHandlingiPhoneOS
14
15 import (
16 "fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/"
17 )
18
19 // Event is a touch event.
20 type Eventscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/event/touch`/Event# struct {
21 // X and Y are the touch location, in pixels.
22 Xscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/event/touch`/Event#X., Yscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/event/touch`/Event#Y. float32
23
24 // Sequence is the sequence number. The same number is shared by all events
25 // in a sequence. A sequence begins with a single TypeBegin, is followed by
26 // zero or more TypeMoves, and ends with a single TypeEnd. A Sequence
27 // distinguishes concurrent sequences but its value is subsequently reused.
28 Sequencescip-go gomod golang.org/x/mobile . `golang.org/x/mobile/event/touch`/Event#Sequence. Sequencescip-go gomod golang.org/x/mobile . `golang.org/x/mobile/event/touch`/Sequence#
29
30 // Type is the touch type.
31 Typescip-go gomod golang.org/x/mobile . `golang.org/x/mobile/event/touch`/Event#Type. Typescip-go gomod golang.org/x/mobile . `golang.org/x/mobile/event/touch`/Type#
32 }
33
34 // Sequence identifies a sequence of touch events.
35 type Sequencescip-go gomod golang.org/x/mobile . `golang.org/x/mobile/event/touch`/Sequence# int64
36
37 // Type describes the type of a touch event.
38 type Typescip-go gomod golang.org/x/mobile . `golang.org/x/mobile/event/touch`/Type# byte
39
40 const (
41 // TypeBegin is a user first touching the device.
42 //
43 // On Android, this is a AMOTION_EVENT_ACTION_DOWN.
44 // On iOS, this is a call to touchesBegan.
45 TypeBeginscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/event/touch`/TypeBegin. Typescip-go gomod golang.org/x/mobile . `golang.org/x/mobile/event/touch`/Type# = iota
46
47 // TypeMove is a user dragging across the device.
48 //
49 // A TypeMove is delivered between a TypeBegin and TypeEnd.
50 //
51 // On Android, this is a AMOTION_EVENT_ACTION_MOVE.
52 // On iOS, this is a call to touchesMoved.
53 TypeMovescip-go gomod golang.org/x/mobile . `golang.org/x/mobile/event/touch`/TypeMove.
54
55 // TypeEnd is a user no longer touching the device.
56 //
57 // On Android, this is a AMOTION_EVENT_ACTION_UP.
58 // On iOS, this is a call to touchesEnded.
59 TypeEndscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/event/touch`/TypeEnd.
60 )
61
62 func (t Typescip-go gomod golang.org/x/mobile . `golang.org/x/mobile/event/touch`/Type#) Stringscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/event/touch`/Type#String().() string {
63 switch t {
64 case TypeBeginscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/event/touch`/TypeBegin.:
65 return "begin"
66 case TypeMovescip-go gomod golang.org/x/mobile . `golang.org/x/mobile/event/touch`/TypeMove.:
67 return "move"
68 case TypeEndscip-go gomod golang.org/x/mobile . `golang.org/x/mobile/event/touch`/TypeEnd.:
69 return "end"
70 }
71 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().("touch.Type(%d)", t)
72 }