首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在VPython中正确实现鼠标事件(无效语法错误)?

如何在VPython中正确实现鼠标事件(无效语法错误)?
EN

Stack Overflow用户
提问于 2018-09-08 01:35:15
回答 1查看 167关注 0票数 0

我试着用鼠标拖动物体。因此,当我让它们使用鼠标时,它们就有了鼠标的新位置。我有两个问题。1.在Glowscript中,它会运行,但没有松开鼠标的操作。当我单击它时,我可以拖动它。但当我想松开鼠标时,它会继续拖动对象,直到我关闭程序。2.我不能在Python编辑器中运行它,bc我得到以下错误:scene.bind("mousedown", def():

完整代码:

代码语言:javascript
复制
drag=False
R = vec(0,0,0)
scene.bind("mousedown", def():
    global drag
    drag=True

    scende.bind("mouseup", def():
        global drag
        drag=False
    )
)

while (True):

    rate(framerate)  
    if drag:
        R=scene.mouse.pos
        e.pos=R
    if running

当然,这段代码中还缺少一些东西。在它上面,我生成常量和对象,在if running下,函数是。这是拖动事件的代码,错误之处在于此。

EN

回答 1

Stack Overflow用户

发布于 2018-09-08 02:42:21

代码语言:javascript
复制
drag=False
R = vec(0,0,0)
scene.bind("mousedown", def():
    global drag
    drag=True

    scene.bind("mouseup", def():
        global drag
        drag=False
    )
)

while (True):

    rate(framerate)  
    if drag:
        R=scene.mouse.pos
        e.pos=R
    if running
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/52227235

复制
相关文章

相似问题

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