psychopy.org | Reference | Downloads | Github

mouse.isPressedIn() with slider

Hello everyone,

I want to have participants answer with a rating on the slider. I want them to see with a marker what rating they clicked on. As stated in previous posts, the “force end of routine” does not allow for that, as it ends the routine before the marker is drawn.
Is there a way I could have the routine end, say 0.5 seconds after they click on the slider?
I’ve found code that works for text components in this post Forcing End of Routine One Second After Mouse Click
#Begin routine
clicked = False # flag for starting timer

Each frame

if mouse.isPressedIn(text) and not clicked:
clicked = True
endTime = t

if clicked and t > endTime + 0.5:
continueRoutine = False

So my question is, does that work also for slider components? When I try to change it to mouse.isPressedIn(slider), it ignores the code and ends the routine immediately on click.
I don’t have much experience with coding, so any ideas would be appreciated! Thanks in advance!

This is possible, but I think there’s an easier way to achieve what you want - rather than delaying the end of the routine after a click, why not add another routine afterwards which is 0.5 seconds long, containing a read-only Slider whose value is set to the same as the previous Slider? Attached is an example of this effect

readOnlySlider.psyexp (9.1 KB)

Hey, thanks for the idea! That makes a lot of sense and sounds easy to implement. Unfortunately I cannot access the experiment you attached. When I try to run it it says that some parameters are not supported in this version of PsychoPy. I changed the version in experiment settings to “blank” then and now all I encounter is “unhandled internal error”:
Traceback (most recent call last):
File “C:\Program Files\PsychoPy3\lib\site-packages\psychopy\app\builder\builder.py”, line 1066, in runFile
self.app.runner.panel.runLocal(event)
File “C:\Program Files\PsychoPy3\lib\site-packages\psychopy\app\runner\runner.py”, line 559, in runLocal
exp=self.loadExperiment())
File “C:\Program Files\PsychoPy3\lib\site-packages\psychopy\scripts\psyexpCompile.py”, line 73, in generateScript
compileScript(infile=exp, version=None, outfile=filename)
File “C:\Program Files\PsychoPy3\lib\site-packages\psychopy\scripts\psyexpCompile.py”, line 242, in compileScript
_makeTarget(thisExp, outfile, targetOutput)
File “C:\Program Files\PsychoPy3\lib\site-packages\psychopy\scripts\psyexpCompile.py”, line 221, in makeTarget
script = thisExp.writeScript(outfile, target=targetOutput)
File “C:\Program Files\PsychoPy3\lib\site-packages\psychopy\experiment_experiment.py”, line 202, in writeScript
self_copy.settings.writeWindowCode(script) # create our visual.Window()
File "C:\Program Files\PsychoPy3\lib\site-packages\psychopy\experiment\components\settings_init
.py", line 768, in writeWindowCode
buff.writeIndentedLines(code % self.params)
File “C:\Program Files\PsychoPy3\lib\site-packages\psychopy\experiment\params.py”, line 215, in str
self.valType)
TypeError: Can’t represent a Param of type color

That’s pretty much my solution

Whoops! I forgot to change the “Use Version” - if you’re opening it in the previous release it’ll do that. You can try this file instead or update your install to the new version (it only came out yesterday)

readOnlySlider.psyexp (9.2 KB)