display error message once mouse movement stops for 200ms


Author
Message
peter.k.p
peter.k.p
Respected Member (380 reputation)Respected Member (380 reputation)Respected Member (380 reputation)Respected Member (380 reputation)Respected Member (380 reputation)Respected Member (380 reputation)Respected Member (380 reputation)Respected Member (380 reputation)Respected Member (380 reputation)
Group: Forum Members
Posts: 13, Visits: 307
Hi there,
I want to display an error message when the mouse movement stops for 200ms in a trial (see for what I tried below which does not work yet). I also want to add a /timeout for 4000ms. Is there a way to specify both within one trial? Thanks for all suggestions, I appreciate it.


<trial ydecrease>
/ ontrialbegin = [
       values.errortype = 2
        values.starttime = script.elapsedtime;
]
/ inputdevice = mouse
/ stimulusframes = [1 = clearscreen, left, right, stim_left, default_stim_right]
/ timeout = 200
/ validresponse = (mousemove,noresponse)
/ responsetrial = ("noresponse", trial.error) // if there is no mouse movement for 200ms show error message
/ ontrialend = [
    values.mouse_change = abs(values.mouse_y - trial.ydecrease.responsey);
]
/ branch = [
    if (expressions.ismouseinrectangle) {
        return trial.clickresponse;
        values.mouse_y = trial.ydecrease.responsey;        
    } else if (trial.ydecrease.responsey <= values.mouse_y) {
        values.mouse_y = trial.ydecrease.responsey;
        return trial.ydecrease;
    } else if (trial.ydecrease.responsey > values.mouse_y) {
        values.changedirection += 1;
        values.errortype = 1;
        return trial.error;}
]
/recorddata = true
</trial>


<trial error>
/ inputdevice = mouse
/ ontrialbegin = [
        values.starttime = script.elapsedtime;
        if(values.errortype == 1)
        trial.error.insertstimulustime(text.error_moved_down, 0)
        else if(values.errortype == 2)
        trial.error.insertstimulustime(text.error_movement_stopped, 0)
        else if(values.errortype == 3)
        trial.error.insertstimulustime(text.error_no_click, 0)
]
/ stimulusframes = [1 = clearscreen]
/ validresponse = (0)
/ timeout = 1000
/ branch = [
        values.mouse_y = trial.error.responsey;
        values.finalresponse = "aborted";
        trial.pressstart
]
/ recorddata = true
</trial>


<text error_moved_down>
/ items = ("Mouse moved down!")
/ position = (50%, 50%)
/ fontstyle = ("Arial", 5%, true, false, false, false, 5, 0)
/ txcolor = white
/ txbgcolor = red
/ erase = ""
</text>

<text error_movement_stopped>
/ items = ("Mouse movement stopped!")
/ position = (50%, 50%)
/ fontstyle = ("Arial", 5%, true, false, false, false, 5, 0)
/ txcolor = white
/ txbgcolor = red
/ erase = ""
</text>

<text error_no_click>
/ items = ("Response too slow!")
/ position = (50%, 50%)
/ fontstyle = ("Arial", 5%, true, false, false, false, 5, 0)
/ txcolor = white
/ txbgcolor = red
/ erase = ""
</text>


GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...





Reading This Topic

Explore
Messages
Mentions
Search