|
|
|
|
|
|
|
|
|
|
namespace Unity.UIWidgets.gestures { |
|
|
|
public class TapDownDetails { |
|
|
|
public TapDownDetails(Offset globalPosition = null) { |
|
|
|
public TapDownDetails(Offset globalPosition = null, |
|
|
|
Offset localPosition = null, |
|
|
|
PointerDeviceKind kind = PointerDeviceKind.touch) { |
|
|
|
this.localPosition = localPosition ?? this.globalPosition; |
|
|
|
this.kind = kind; |
|
|
|
|
|
|
|
public readonly Offset localPosition; |
|
|
|
|
|
|
|
public readonly PointerDeviceKind kind; |
|
|
|
public TapUpDetails(Offset globalPosition = null) { |
|
|
|
public TapUpDetails(Offset globalPosition = null, |
|
|
|
Offset localPosition = null, |
|
|
|
PointerDeviceKind kind = PointerDeviceKind.touch, |
|
|
|
int device = 0) { |
|
|
|
this.localPosition = localPosition ?? this.globalPosition; |
|
|
|
this.kind = kind; |
|
|
|
this.device = device; |
|
|
|
|
|
|
|
public readonly Offset localPosition; |
|
|
|
|
|
|
|
public readonly PointerDeviceKind kind; |
|
|
|
|
|
|
|
public readonly int device; |
|
|
|
} |
|
|
|
|
|
|
|
public delegate void GestureTapUpCallback(TapUpDetails details); |
|
|
|
|
|
|
protected override void handlePrimaryPointer(PointerEvent evt) { |
|
|
|
if (evt is PointerUpEvent) { |
|
|
|
this._finalPosition = evt.position; |
|
|
|
|
|
|
|
|
|
|
|
this._checkUp(); |
|
|
|
this._checkUp(evt); |
|
|
|
} |
|
|
|
} |
|
|
|
else if (evt is PointerCancelEvent) { |
|
|
|
|
|
|
if (pointer == this.primaryPointer) { |
|
|
|
this._checkDown(); |
|
|
|
this._wonArenaForPrimaryPointer = true; |
|
|
|
this._checkUp(); |
|
|
|
this._checkUp(null); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
void _checkUp() { |
|
|
|
void _checkUp(PointerEvent evt) { |
|
|
|
this.onTapUp(new TapUpDetails(globalPosition: this._finalPosition)); |
|
|
|
this.onTapUp(new TapUpDetails(globalPosition: this._finalPosition, |
|
|
|
kind: evt?.kind ?? PointerDeviceKind.touch, |
|
|
|
device: evt?.device ?? 0)); |
|
|
|
return null; |
|
|
|
}); |
|
|
|
} |
|
|
|