WorldViz User Forum

WorldViz User Forum (
-   Vizard (
-   -   Allow and record mouse clicks in 5s of wait time (

Vishav 12-07-2018 09:58 PM

Allow and record mouse clicks in 5s of wait time
I need to give 5s time to the user to make choice. Meanwhile, I want to record mouse clicks that user do in those 5s and write position of mouse click on screen in the database. How both of them are possible at the same time?

Jeff 12-12-2018 04:31 AM

You can use the viztask.waitAny command to wait for either a mouse event or a time event.

Vishav 12-12-2018 06:32 AM

But with waitAny task move to next trial after the first mouse click. However, I want the task to remain same for 5s in spite of mouse click.

Jeff 12-13-2018 12:52 AM

The following code waits for a signal sent after 5 seconds or a mouse left button press. The code will loop and count the mouse clicks until the signal event occurs:


import viz
import viztask
import vizact


s = viztask.Signal()
waitMouse = viztask.waitMouseDown(viz.MOUSEBUTTON_LEFT)
waitSignal = s.wait()

def mouseTask():
        mouseCounter = 0
        while True:
                d = yield viztask.waitAny([waitMouse,waitSignal])
                if d.condition == waitSignal:
                        mouseCounter +=1
        print mouseCounter

viztask.schedule( mouseTask() )

Vishav 12-13-2018 02:18 AM

Thanks a lot

All times are GMT -7. The time now is 01:14 PM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2022, vBulletin Solutions, Inc.
Copyright 2002-2018 WorldViz LLC