I have created a “continue” button using the following code. It is supposed to be conditional, only appearing when the participant has answered multiple slider questions on the screen. However, it appears right away and is functional when I test it online. Does anyone know why this is?
Button code: using the “both” option instead of Auto->JS.
In begin experiment (Py side):
continueButton = visual.ShapeStim(win, fillColor= [0.3, 0.3, 0.3], fillColorSpace='rgb', vertices=((-0.08, -0.05), (-0.08, 0.05), (0.08, 0.05), (0.08, -0.05)), closeShape=True, pos=(.70, -.40), name='continueButton')
continueButtonText = visual.TextStim(win, text='Continue', height = 0.03, pos=(.70, -.40))
continueButtonSelected = False
In begin experiment (JS side):
continueButton = new visual.ShapeStim({"win":psychoJS.window,"fillColor": [0.3, 0.3, 0.3], "fillColorSpace": "rgb", "vertices": [[(- 0.08), (- 0.05)], [(- 0.08), 0.05], [0.08, 0.05], [0.08, (- 0.05)]], "closeShape": true, "pos": [0.7, (- 0.4)], "name": "continueButton"});
continueButtonText = new visual.TextStim({"win":psychoJS.window, "text": "Continue", "height": 0.03, "pos": [0.7, (- 0.4)]});
continueButtonSelected = false;
In begin routine (Py side):
effortRate_resp = event.Mouse(win=win)
continueButton.setAutoDraw(False)
continueButtonText.setAutoDraw(False)
continueButtonSelected = False
nasaAnswered = False
In begin routine (JS side):
mouse = new core.Mouse({win: psychoJS.window});
continueButton.setAutoDraw(false);
continueButtonText.setAutoDraw(false);
continueButtonSelected = false;
nasaAnswered = false;
In each frame (Py side):
if effortRate_resp.isPressedIn(continueButton):
continueButtonSelected = True
if continueButtonSelected:
continueRoutine = False
In each frame (JS side):
if ((continueButton.contains(mouse)) & (mouse.getPressed()[0] === 1)) {
continueButtonSelected = true;
if (continueButtonSelected) {
continueRoutine = false;
}
}