浏览代码

tap up returns more information

/main
xingwei.zhu 5 年前
当前提交
46bf22cf
共有 1 个文件被更改,包括 29 次插入7 次删除
  1. 36
      Runtime/gestures/tap.cs

36
Runtime/gestures/tap.cs


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;
});
}

正在加载...
取消
保存