浏览代码

longpressup support

/main
xingwei.zhu 5 年前
当前提交
5dee2b7a
共有 2 个文件被更改,包括 23 次插入2 次删除
  1. 20
      Runtime/gestures/long_press.cs
  2. 5
      Runtime/widgets/gesture_detector.cs

20
Runtime/gestures/long_press.cs


base(deadline: Constants.kLongPressTimeout, debugOwner: debugOwner, kind: kind) {
}
bool _longPressAccepted = false;
public GestureLongPressUpCallback onLongPressUp;
this._longPressAccepted = true;
if (this.onLongPress != null) {
this.invokeCallback<object>("onLongPress", () => {
this.onLongPress();

protected override void handlePrimaryPointer(PointerEvent evt) {
if (evt is PointerUpEvent) {
this.resolve(GestureDisposition.rejected);
if (this._longPressAccepted && this.onLongPressUp != null) {
this._longPressAccepted = false;
this.invokeCallback<object>("onLongPressUp", () => {
this.onLongPressUp();
return null;
});
}
else {
this.resolve(GestureDisposition.rejected);
}
}
else if (evt is PointerDownEvent || evt is PointerCancelEvent) {
this._longPressAccepted = false;
}
}

5
Runtime/widgets/gesture_detector.cs


gestures[typeof(LongPressGestureRecognizer)] =
new GestureRecognizerFactoryWithHandlers<LongPressGestureRecognizer>(
() => new LongPressGestureRecognizer(debugOwner: this),
instance => { instance.onLongPress = this.onLongPress; }
instance => {
instance.onLongPress = this.onLongPress;
instance.onLongPressUp = this.onLongPressUp;
}
);
}

正在加载...
取消
保存