Skip to content
This repository was archived by the owner on Apr 29, 2021. It is now read-only.

Commit 2b4e3f7

Browse files
committed
clear unused functions + refine flutter mouse tracker => leave then enter
1 parent 65080d8 commit 2b4e3f7

File tree

2 files changed

+14
-56
lines changed

2 files changed

+14
-56
lines changed

Runtime/gestures/binding.cs

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -109,51 +109,6 @@ void _handlePointerScrollEvent(PointerEvent evt) {
109109
this.dispatchEvent(evt, result);
110110
}
111111

112-
void _handlePointerHoverEvent(PointerEvent evt) {
113-
HitTestResult result = new HitTestResult();
114-
this.hitTest(result, evt.position);
115-
116-
D.assert(this._enteredTargets.Count == 0);
117-
foreach (var hitTestEntry in result.path) {
118-
if (this.lastMoveTargets.Contains(hitTestEntry.target)) {
119-
hitTestEntry.target.handleEvent(evt, hitTestEntry);
120-
this.lastMoveTargets.Remove(hitTestEntry.target);
121-
}
122-
else {
123-
this._enteredTargets.Add(hitTestEntry);
124-
}
125-
}
126-
127-
//leave events
128-
foreach (var lastMoveTarget in this.lastMoveTargets) {
129-
lastMoveTarget.handleEvent(new PointerExitEvent(
130-
timeStamp: evt.timeStamp,
131-
pointer: evt.pointer,
132-
device: evt.device,
133-
kind: evt.kind
134-
), null);
135-
}
136-
137-
//enter events
138-
foreach (var hitTestEntry in this._enteredTargets) {
139-
hitTestEntry.target.handleEvent(new PointerEnterEvent(
140-
timeStamp: evt.timeStamp,
141-
pointer: evt.pointer,
142-
device: evt.device,
143-
kind: evt.kind
144-
), hitTestEntry);
145-
}
146-
147-
this.lastMoveTargets.Clear();
148-
foreach (var hitTestEntry in result.path) {
149-
this.lastMoveTargets.Add(hitTestEntry.target);
150-
}
151-
152-
this._enteredTargets.Clear();
153-
154-
this.dispatchEvent(evt, result);
155-
}
156-
157112
public virtual void hitTest(HitTestResult result, Offset position) {
158113
result.add(new HitTestEntry(this));
159114
}

Runtime/gestures/mouse_tracking.cs

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -168,17 +168,7 @@ void exitAllDevices(_TrackedAnnotation trackedAnnotation) {
168168
}
169169

170170
_TrackedAnnotation hitAnnotation = this._findAnnotation(hit);
171-
if (!hitAnnotation.activeDevices.Contains(deviceId)) {
172-
hitAnnotation.activeDevices.Add(deviceId);
173-
if (hitAnnotation.annotation?.onEnter != null) {
174-
hitAnnotation.annotation.onEnter(PointerEnterEvent.fromHoverEvent(lastEvent));
175-
}
176-
}
177-
178-
if (hitAnnotation.annotation?.onHover != null) {
179-
hitAnnotation.annotation.onHover(PointerHoverEvent.fromHoverEvent(lastEvent));
180-
}
181-
171+
//leave
182172
foreach (_TrackedAnnotation trackedAnnotation in this._trackedAnnotations.Values) {
183173
if (hitAnnotation == trackedAnnotation) {
184174
continue;
@@ -192,6 +182,19 @@ void exitAllDevices(_TrackedAnnotation trackedAnnotation) {
192182
trackedAnnotation.activeDevices.Remove(deviceId);
193183
}
194184
}
185+
186+
//enter
187+
if (!hitAnnotation.activeDevices.Contains(deviceId)) {
188+
hitAnnotation.activeDevices.Add(deviceId);
189+
if (hitAnnotation.annotation?.onEnter != null) {
190+
hitAnnotation.annotation.onEnter(PointerEnterEvent.fromHoverEvent(lastEvent));
191+
}
192+
}
193+
194+
//hover
195+
if (hitAnnotation.annotation?.onHover != null) {
196+
hitAnnotation.annotation.onHover(PointerHoverEvent.fromHoverEvent(lastEvent));
197+
}
195198
}
196199
}
197200
}

0 commit comments

Comments
 (0)