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\”, line 1066, in runFile
File “C:\Program Files\PsychoPy3\lib\site-packages\psychopy\app\runner\”, line 559, in runLocal
File “C:\Program Files\PsychoPy3\lib\site-packages\psychopy\scripts\”, line 73, in generateScript
compileScript(infile=exp, version=None, outfile=filename)
File “C:\Program Files\PsychoPy3\lib\site-packages\psychopy\scripts\”, line 242, in compileScript
_makeTarget(thisExp, outfile, targetOutput)
File “C:\Program Files\PsychoPy3\lib\site-packages\psychopy\scripts\”, line 221, in makeTarget
script = thisExp.writeScript(outfile, target=targetOutput)
File “C:\Program Files\PsychoPy3\lib\site-packages\psychopy\”, 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\”, line 215, in str
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)

It does exactly what I wanted, thanks so much!

Hi wakecarter,
is it possible to change the color of the marker? Right now it is a red dot, and in other sliders in my experiment I changed it to white with the following code:

try {
    if ( !== {
        Assoziationen_Ratingslider._markerColor = col;
        Assoziationen_Ratingslider._marker.lineStyle(1,, 1, 0.5);
        Assoziationen_Ratingslider._marker.beginFill(, 1);
        Assoziationen_Ratingslider._marker.drawCircle(0, 0, newMarkerSize / 2);
        Assoziationen_Ratingslider._needUpdate = true;
} catch (err) {}

However, this does not seem to work when I add it to your code. Do you have an idea how to work around this?

I’m afraid that I don’t understand what all that code is trying to do. It seems to be a lot just to change a colour.

However, for colour changes in code you do need to pay attention to creating them using new util.Color. There’s a suggestion in my crib sheet for defining them in a Both component.

That was what I was missing, the “new util.Color”. Thanks for all the quick help! I think I’m all set now