首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >scroll_to()行为

scroll_to()行为
EN

Stack Overflow用户
提问于 2016-10-17 12:26:27
回答 1查看 61关注 0票数 2

我在我的kv文件中使用了scroll_to函数。它按我的意愿正确滚动,但如果我转动鼠标轮,它将在scroll_to()之前跳回原来的位置。

任何想法,我怎样才能改进我的代码?

我的kv文件片段:

代码语言:javascript
复制
MyButton:
    text: 'jump'
    on_release: scroll_content.scroll_to(jump_id_2, padding=0, animate=True)

ScrollView:
    id: scroll_content
    blah, blah, blah.......

    # values of the devices
    GridLayout:

        BoxLayout:
            id: jump_id_0
            blah, blah, blah.......

        BoxLayout:
            id: jump_id_1
            blah, blah, blah.......

        BoxLayout:
            id: jump_id_2
            blah, blah, blah.......

谢谢你的帮助..。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-11-15 10:00:47

我设法找到了一个“解决方案”:基本上您在"content“上设置了scroll_type,然后单击屏幕上的某个地方.

代码语言:javascript
复制
MyButton:
    text: 'jump'
    on_release: scroll_content.scroll_to(jump_id_2, padding=0, animate=True); app.click(200)

ScrollView:
    id: scroll_content
    scroll_type: ['content']
    blah, blah, blah.......

    # values of the devices
    GridLayout:

        BoxLayout:
            id: jump_id_0
            blah, blah, blah.......

        BoxLayout:
            id: jump_id_1
            blah, blah, blah.......

        BoxLayout:
            id: jump_id_2
            blah, blah, blah.......

其中,单击函数是:

代码语言:javascript
复制
def click(self, shift):
"""Click on the screen."""
        pt = POINT()
        ctypes.windll.user32.GetCursorPos(ctypes.byref(pt))
        ctypes.windll.user32.SetCursorPos(pt.x, pt.y + shift)
        ctypes.windll.user32.mouse_event(2, pt.x, pt.y + shift, 0, 0)
        ctypes.windll.user32.mouse_event(4, pt.x, pt.y + shift, 0, 0)
        ctypes.windll.user32.SetCursorPos(pt.x, pt.y)
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/40086368

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档