Flutter:使用手势检测器禁用多点触控/拖动 [英] Flutter: Disabling Multi-Touch/Drag with Gesture Detector

查看:276
本文介绍了Flutter:使用手势检测器禁用多点触控/拖动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在构建具有多个手柄的Slider小部件,并且目前正在实现Gesture Detector.我遇到一个问题,如果您用第二根手指触摸/拖动屏幕,检测器将识别它并调用onDragUpdate函数,这是我要禁用的功能-在一根手指拖动手柄的同时,手势检测器不应调用第二根手指的更新,但仍应允许第一根手指调用更新.

Im currently building a Slider widget which multiple handle and am currently implementing the Gesture Detector. I am having an issue where if you touch/drag the screen with a second finger it will be recognised by the detector and call the onDragUpdate function, which is what I am trying to disable - whilst one finger is dragging the handle around, the gesture detector shouldn't call updates for a second finger but should still allow the first finger to call the updates.

例如,如果您用手指1(精细)滑动手柄,然后添加第二个手指(手指2),则即使两个手指都在屏幕上,手势检测器也只能识别手指1.

For example, if you're sliding the handle around with finger 1 (fine) and then add a second finger, finger 2, the gesture detector should only recognise finger 1 even though both fingers are on screen.

我知道Listener类中有一个函数,可以让您指定设备(使用details.device),但是有没有一种方法可以使用Gesture Detector类来实现呢?

I understand there is a function in the Listener class which allows you to specify a device (using details.device) but is there a way to achieve this using the Gesture Detector class?

当前正在研究手势检测器的不同实现者,包括查看此答案 https://stackoverflow.com/a/56037327/12147590 ,但我仍在挣扎.如果有人可以指出正确的方向或以简单的方式进一步解释答案,那将非常好,欢呼:)

Currently looking into different implementers for the Gesture Detector, including looking at this answer https://stackoverflow.com/a/56037327/12147590 but i'm still struggling. If anyone could point me in the right direction or explain the answer further in simple terms for me that would be great, cheers :)

推荐答案

当我在处理另一个单独的问题时,我碰巧也使用解决方案

Whilst I was working on another separate problem I happened to have also solved this problem by using the solution here

这篇关于Flutter:使用手势检测器禁用多点触控/拖动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆