覆盖内置的on_touch_down和on_touch_move方法后,如何手动使滚动管理器工作?

时间:2019-11-27 19:19:32

标签: python kivy

因此,我设法通过说on_touch_down如果x和y是正确的(在按钮所在的位置)来使按钮在我的应用程序中起作用,

self.tagasi.dispatch('on_press')

'tagasi'是按钮的名称。 现在,下一个障碍是如何使scrollview工作,因为这似乎并不容易。为了让猕猴桃接受触摸输入(我正在为IOS开发此应用程序),我必须手动重写许多功能。不是理想的,但是更少的抱怨,更多​​的工作。 因此,如果按钮的工作方式如下:

def on_touch_down(self, touch):
    if self.manager.current == "sc2":
        if 0 < touch.y/self.height < 0.2 and touch.x/self.width > 0 and touch.x/self.width < 1:
            self.tagasi.state = "down"
            self.tagasi.dispatch('on_press')

使滚动视图工作的等效方法是什么?

我的KV看起来像这样:

Screen:
    name: "sc2"

    size: root.width, root.height
    FloatLayout:

        Button:
            id: tagasi
            size_hint: 1, 0.2
            pos_hint: {"right":1, "bottom": 0}
            text: "go back"
            on_press:
                manager.current = "sc1"
                manager.transition.direction = "right"


    ScrollView:
        do_scroll_x: False
        do_scroll_y: True
        id: kerimine
        Label:
            size_hint_y: None
            height: self.texture_size[1]
            text_size: root.width, root.height
            padding: 10, 10
            text:
                'really some amazing text\n' * 100

我希望ScrollView可以工作,但是不知道如何手动重写所有必需的内容(就像我通过手动将按钮告诉'on_press'来处理按钮一样)

0 个答案:

没有答案