Hi, I used a builder to create a slider, and added a code component to make sure subjects can only interact with the slider by dragging the button. I place this function at the start of routine and it works fine. But I can’t find a way to pass an argument to the slider function, so I don’t have to write a different function for a slider that has different names. When I put the following code in routine tab, nothing changes to my slider. Any help would be greatly appreciated!
click = bool(slider.mouse.getPressed())
xy = slider.mouse.getPos()
if click: # Update current but don't set Rating (mouse is still down) # Dragging has to start inside a "valid" area (i.e., on the # slider), but may continue even if the mouse moves away from # the slider, as long as the mouse button is not released. if (slider.validArea.contains(slider.mouse, units=slider.units) and slider.markerPos is None): slider.markerPos = slider._posToRating(xy) # updates marker slider._dragging = True elif (slider.marker.contains(slider.mouse, units=slider.units) or slider._dragging): slider.markerPos = slider._posToRating(xy) # updates marker slider._dragging = True else: # mouse is up - check if it *just* came up if slider._dragging: slider._dragging = False if slider.markerPos is not None: slider.recordRating(slider.markerPos) return slider.markerPos else: # is up and was already up - move along return None slider._mouseStateXY = xy
Override slider method
slider_test.getMouseResponses = call_slider