Processing mouse events

35 views
Skip to first unread message

Bruce Sherwood

unread,
Oct 7, 2016, 12:55:03 PM10/7/16
to Project Jupyter
Using the vpython module one can drag an object through a 3D scene. Mouse events are sent regularly from the browser to the server, and I gather they are buffered until the Python program reaches the end of a cell, then all of them are sent. I would like to use only the most recent mouse position rather than process all of the buffered events. When reading these messages, is there a way to ask whether I've reached the end of the event buffer?

MinRK

unread,
Oct 10, 2016, 7:26:51 AM10/10/16
to Project Jupyter
It isn't generally possible to know that the end of the buffer has been reached, because these events can just keep coming. There are some options, though:

1. you could set a small delay on handling the event, and restart the counter on each new event. That way, your response is limited to ~50ms, but you will only trigger the handler when there haven't been any new events in that time.
2. use mouseup event, rather than position updates, and only fire when the mouse has finished moving (may not make sense for your use case, if you want to update while dragging)

-Min

On Fri, Oct 7, 2016 at 6:55 PM, Bruce Sherwood <bruce.s...@gmail.com> wrote:
Using the vpython module one can drag an object through a 3D scene. Mouse events are sent regularly from the browser to the server, and I gather they are buffered until the Python program reaches the end of a cell, then all of them are sent. I would like to use only the most recent mouse position rather than process all of the buffered events. When reading these messages, is there a way to ask whether I've reached the end of the event buffer?

--
You received this message because you are subscribed to the Google Groups "Project Jupyter" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jupyter+unsubscribe@googlegroups.com.
To post to this group, send email to jup...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jupyter/d0ae8834-7a86-40f9-a834-3f8fdec0b0cc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages