代码之家  ›  专栏  ›  技术社区  ›  聂超群

何时调用GestureDetector中的OnTaCancel?

  •  1
  • 聂超群  · 技术社区  · 4 年前

    我们每天都使用GestureDetector的onTap,但什么时候会调用ONTACancel?

    我阅读了实现代码,注意到OnTaCancel评论:

      /// The pointer that previously triggered [onTapDown] will not end up causing
      /// a tap.
      ///
      /// This is called after [onTapDown], and instead of [onTapUp] and [onTap], if
      /// the tap gesture did not win.
      ///
      /// See also:
      ///
      ///  * [kPrimaryButton], the button this callback responds to.
      final GestureTapCancelCallback? onTapCancel;
    

    我还是搞不懂一个叫“风景”的onTapCancel,有人能给我举个例子吗?非常感谢:)

    1 回复  |  直到 4 年前
        1
  •  2
  •   MickaelHrndz    4 年前

    它通常在导致 onTapDown 不会导致 onTapUp .例如,你按下一个按钮 GestureDetector ,然后把你的手指移开,放开。

        2
  •  0
  •   Pinak Parate    4 年前

    据我所知,当你在诸如警报、信息等对话框中使用OnTaCancel时,最好使用或调用它。取消对话框会使其弹出,并将用户返回到上一页/状态,这将非常有用。