MCPcopy Create free account
hub / github.com/cogentcore/core / Send

Method Send

events/deque.go:96–125  ·  view source on GitHub ↗

Send adds an event to the end of the deque, replacing the last of the same type unless marked as Unique. They are returned by NextEvent in FIFO order.

(ev Event)

Source from the content-addressed store, hash-verified

94// as Unique.
95// They are returned by NextEvent in FIFO order.
96func (q *Deque) Send(ev Event) {
97 q.LockAndInit()
98 defer q.Mu.Unlock()
99
100 n := len(q.Back)
101 if !ev.IsUnique() && n > 0 {
102 lev := q.Back[n-1]
103 if ev.IsSame(lev) {
104 q.Back[n-1] = ev // replace
105 switch ev.Type() {
106 case MouseMove, MouseDrag:
107 me := ev.(*Mouse)
108 le := lev.(*Mouse)
109 me.Prev = le.Prev
110 me.PrvTime = le.PrvTime
111 case Scroll:
112 me := ev.(*MouseScroll)
113 le := lev.(*MouseScroll)
114 me.Delta = me.Delta.Add(le.Delta)
115 }
116 q.Cond.Signal()
117 if TraceEventCompression {
118 fmt.Println("compressed back:", ev)
119 }
120 return
121 }
122 }
123 q.Back = append(q.Back, ev)
124 q.Cond.Signal()
125}
126
127// SendFirst adds an event to the start of the deque.
128// They are returned by NextEvent in LIFO order,

Callers 13

KeyMethod · 0.45
KeyChordMethod · 0.45
MouseButtonMethod · 0.45
MouseMoveMethod · 0.45
ScrollMethod · 0.45
DropExternalMethod · 0.45
TouchMethod · 0.45
MagnifyMethod · 0.45
CustomMethod · 0.45
iSearchEventMethod · 0.45
qReplaceEventMethod · 0.45
cursorMovedEventMethod · 0.45

Calls 7

LockAndInitMethod · 0.95
PrintlnMethod · 0.80
UnlockMethod · 0.65
IsUniqueMethod · 0.65
IsSameMethod · 0.65
TypeMethod · 0.65
AddMethod · 0.65

Tested by

no test coverage detected