Disable ok button in expInfo session

Hi everyone,

In my experiment, i want the participants to answer some demographic questions (age, gender etc) beofre entering the task. I am wondering whether there is any method to disable the ok button to preceed until all the demographic information is filled. Because by default, even if you leave the expInfo blank, you can still press the ok button to proceed.

Thanks for your help in advance!

I am also keen to do this. Could anybody provide some pointers?

Thanks,

Try adding an asterisk to the end of the field name.

This only works online because in person there would normally be a researcher present.

Hi @sean0820.

After some playing around I managed to do this. What I did was create the ‘continue’ button programatically - in the ‘Begin Routine’ thingo - and immediately set this object to Autodraw(False). Then in the ‘Each Frame’ thingo - check if the conditions had been met to show the button - and if so - set Autodraw(True) for that object. Works - the continue button only appears once your validation conditions are met. (Although my project is currently broken when I upload it to Pavlovia - but this could be because of any number of things… sigh… so caveat emptor and all that.)

Here’s the code I used:

BEGIN ROUTINE
# Create cont button but - not visible yet
ContinueButton_X = visual.ButtonStim(win, 
    text='Continue', font='Arial',
    pos=(.6, -.4),
    letterHeight=0.05,
    size=[.25, .1], borderWidth=0.0,
    fillColor='darkgrey', borderColor=None,
    color='white', colorSpace='rgb',
    opacity=None,
    bold=False, italic=False,
    padding=None,
    anchor='center',
    name='ContinueButton_5'
)
ContinueButton_X.setAutoDraw(False)

EACH FRAME

# RADIO BUTTONS COLOUR CHANGE
if mouse.isPressedIn(Option1Checkbox):
    if t > lastClickTime + clickInterval:  # Debounce
        Option1Checkbox.selected = True
        Option2Checkbox.selected = False
        print("Clicked in box 1")
        HaveVal = True
if mouse.isPressedIn(Option2Checkbox):
    if t > lastClickTime + clickInterval:  # Debounce
        Option2Checkbox.selected = True
        Option1Checkbox.selected = False
        print("Clicked in box 2") 
        HaveVal = True
        
# set the color of clicked and non clicked boxes
for box in boxlist:
    if box.selected:
        box.fillColor = 'green'
    else:
        box.fillColor = 'lightGray'

if HaveVal and not ContButton:
    print("MAKE BUTTON!")
    ContinueButton_X.setAutoDraw(True)
    ContButton=True

Note: you must ALSO enable the mouse component to do it’s little ‘end routine’ thing for valid clicks on the programatically created button AND ensure that the code component is at the TOP of your list of components in builder.

Hope this helps. Good luck.

D.

Oh how annoying - posting this has ripped out all the indentation information in the code I posted above…

grrr…

Hopefully you can work it out.

(sorry)

I’ve put your tabs back in by enclosing your code as preformatted text.

Ahah! So THAT’s the trick.

Thanks @wakecarter !

Will do this myself next time.

:slightly_smiling_face:

D.