Accepting a mouse click only within a ROI? OSweb version.
Hi all
I am trying to run a task online, and I am not sure if it is possible using OSweb.
It the task, participants click on a screen button before the experiment advances to the next trial. A click outside the button (let's call it ROI) should be ignored.
I implemented a version of the task using python (see here https://forum.cogsci.nl/discussion/6458/accepting-a-mouse-click-only-within-a-roi)
But this method cannot be used with OSweb, since there is no way to use functions such as my_mouse.get_click() in java. Please correct me if I am wrong.
So, the task cannot be implemented with java.
@Eduard was kind enough to suggest another method, using the repeat_cycle item.
I implemented his suggestion, and it was successful regarding the desktop version:
In the stim sketchpad I named an element (a box called "box"), and the condition in the repeat_cycle is [cursor_roi]="".
That is, the cycle is repeated unless cursor_roi takes a non-zero value, e.g. the value "box" (or whatever). But, named elements are not supported in OSweb, correct? Although I don't use the "box" value, naming an element causes OSweb to crash.
So, the task cannot be implemented with the repeat_cycle approach either, correct?
I would greatly appreciate your comment, since I am unfortunately thinking about using alternative software.
Can any of you think of another way to implement the "only-accept-a-click-within-a-roi" functionality with OSweb?
Thank you for your time,
Fotis
Comments
Hi again
Any ideas? Or perhaps a comment?
Thank you,
Fotis
Hi Fotis,
I think you are right. Cursor_roi relies on named items and therefore OSweb wouldn't support them.
I have no idea how difficult it is to implement in javascript. On the one hand, it doesn't appear too tricky (see e.g. here), but then, I wouldn't know why it wouldn't be implemented if it was that easy. So there is probably somewhere some restrictions introduced by the OS framework.
However (I just tried something), and it seems, that you can still retrieve the cursor position of a mouse click. So based on that info, you will probably be able to do some javascript computation to decide whether to repeat a trial or not. I think. Attached a brief example experiment that demonstrates what I mean. Basically, you have to use the variable vars. cursor_x and vars.cursor_y).
Hope this helps,
Eduard
Hi @eduard
Thank you so much for your effort!
I am not that familiar with javascript, nor web-programming. I'll have to invest some time to try out your suggestion and program a fully counterbalanced experiment.
I'll let you know in case I make it!
Thank you,
Fotis
Hi Fotis,
Advancing to the next trial only when participants clicked within a certain region requires a bit of JavaScript code, but should definitely be possible. If you need help, feel free to post your experiment here.
Cheers,
Lotje
Did you like my answer? Feel free to