区分鼠标按下和鼠标按住
我目前正在为 pyglet 开发一个小型图形库。该模块用于制作完全由线条组成的矢量图形。
在其开发过程中,我遇到了一个问题,单击拖动(并移动一个点)也会导致触发 on_mouse_press 事件,该事件在最后一个活动链接和您尝试拖动的点之间创建一个新链接。
我似乎想不出任何方法来解决这个问题,不会让在点之间创建链接感觉很滞后,我在 on_mouse_release 上创建了链接,这样我就可以确定在链接点之前鼠标是否已被拖动。
有没有其他人对我如何让它在不显得迟缓的情况下工作有任何好主意。
编辑:澄清我使用 pyglet 和 python
Im currently working on a little graphics library for pyglet. The module is used to make vector graphics composed entirely of lines.
In its develoment i have have run into a problem where, clicking to drag (and move a point) also causes fires an on_mouse_press event that creates a new link between the last active link and the point you are trying to drag.
I cant seem to think of any way to fix this that dosent make creating links between points feel laggy, i have creating links on_mouse_release instead so that i could determine if the mouse had been draged before linking the point.
Does anyone else have any bright ideas on how i can get this to work without appearing laggy.
EDIT: to clarify im using pyglet with python
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
简短描述:
我知道这是一个老问题,但它处于“未回答”状态,因此希望能够解决它并从列表中删除。
Short description:
I know it's an old question, but it's under the "unanswered" so hoping to get it resolved and out of the list.
在 MouseDown 上设置一个布尔变量以指示应忽略其他事件。
当然,您需要调整它才能与您的代码一起使用,但这应该是一个好的开始。
On MouseDown set a boolean variable to indicate that other events should be ignored.
You'll need to tweak this to work with your code of course but it should be a good start.