How do I implement GetClicks function (or if there is any alternative function in Psyctoolbox) if subject does not click within a certain time frame. For example: I wish to give subject a screen and ask them to click on certain stimuli within a certain amount of time (say 5sec) but if no click after this time, I want to present different stimuli.
I have got the solution - cheers…!
It’s simply need to combine buttons and x, y coordinate with the if statement in the while loop with tic toc.
Example: This loop will break while loop either time limit of 5 sec or left mouse click (whichever is earlier)
start = GetSecs;
while (GetSecs - start) < 5
[x1,y1,buttons,~,~,~] = GetMouse();
if ((x1,y1) in an area and buttons(1) == 1)
break;
end
end
The next PTB beta release will contain some improvements to allow specifiying a timeout to GetClicks, e.g., citing from the help text of future GetClicks:
% [clicks,x,y,whichButton,clickSecs] = GetClicks(window, 0.2, [], GetSecs + 5);
% would wait up to 5 seconds in total for the first click to happen, and then
% another 0.2 seconds for a 2nd click, then 0.2 seconds for a 3rd click…
One can also use the KbQueue functions for high timing precision background logging of mouse button clicks, and on Linux/X11 and MS-Windows for recording mouse trajectories, cfe. “help MouseMotionRecordingDemo” - this not on Apples trainwrecks though.