英文:
onTapDown in Flutter doesn't register quick taps
问题
我有这段代码来检测轻按操作:
GestureDetector(
onTapDown: (details) {
// 执行操作
},
它运行正常,除了对于非常短的轻按操作。
根据文档:
> 这是在经过短暂的超时后调用的,即使尚未选择获胜手势。如果轻按手势获胜,将调用[onTapUp],否则将调用[onTapCancel]。
为什么会有超时?我能去掉这个超时吗?
英文:
I have this code to detect a tapdown:
GestureDetector(
onTapDown: (details) {
// do action
},
It works fine, except for really short taps.
From the documentation:
> This is called after a short timeout, even if the winning gesture has not yet been selected. If the tap gesture wins, [onTapUp] will be called, otherwise [onTapCancel] will be called.
Why the timeout? Can I get rid of the timeout?
答案1
得分: 0
onPanDown
立即触发。使用:
GestureDetector(
onPanDown: (details) {
// 执行操作
},
解决了我的问题。
英文:
onPanDown
is instantly triggered. Using:
GestureDetector(
onPanDown: (details) {
// do action
},
Solved my issue.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论