触地、上升和移动之间的区别

Difference between on touch down, up and move

由于我对on_touch_down()之间的含义和区别有点困惑, on_touch_move(), on_touch_up()。谁能解释一下这些功能是如何工作的?

注意: 我已经看了文档,还是没看懂。

为了正确解释,我将使用以下示例:

from kivy.app import App
from kivy.uix.widget import Widget

class MyWidget(Widget):
    def on_touch_down(self, touch):
        print("on_touch_down")
        return super(MyWidget, self).on_touch_down(touch)

    def on_touch_move(self, touch):
        print("on_touch_move")
        return super(MyWidget, self).on_touch_move(touch)

    def on_touch_up(self, touch):
        print("on_touch_up")
        return super(MyWidget, self).on_touch_up(touch)

class MyApp(App):
    def build(self):
        return MyWidget()

if __name__ == '__main__':
    MyApp().run()

如果我们用鼠标按下,然后移动它,然后释放它,我们得到以下结果:

on_touch_down
on_touch_move
on_touch_move
on_touch_move
...
on_touch_move
on_touch_move
on_touch_move
on_touch_up

这正是这 3 个事件中管理的内容:

on_touch_down:第一次按下鼠标时调用

on_touch_move: 按住鼠标移动时调用

on_touch_up:松开鼠标时调用