Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

Inline_script: Text input & Ok button

Hi all!

I've been trying to figure out how you can make a form or inline script with a text_input and an OK button. However, every time I try the OK button does not work. It seems like the text_input field is selected: when I enter some text and press Enter, I can subsequently use the OK button. But when I just type some text and press the OK button, nothing happens. I've been reading through previous topics, but can't figure out a way that would work.
Here's my code so far:

from libopensesame import widgets
form = widgets.form(exp)

form = widgets.form(exp, cols=[1,1,1,1], rows=[1,1,1,1,1], margins=(50,50,50,50), spacing=10)
text_input = widgets.text_input(form, var='naam', return_accepts=False, stub=u"Typ hier")
nextButton = widgets.button(form, text='Next', var="buttonpress")

form.set_widget(b1, (0,0))
form.set_widget(text_input, (0,1), colspan=4)
form.set_widget(nextButton, (3,4))

Thank you in advance!!



  • Hi Jenna,

    Welcome to the forum!

    It is a bit unclear to me what the exact issue is and what is exactly is that you want the form to do. Do you want to avoid participants having to press Enter before they can use the Next button? Because i don't think that is possible, the text input widget will be activated for as long as the participant did not press Tab or Enter.

    Would it help to set return_accepts=True and remove the Next button alltogether?


  • Hi Laurent, and goedenavond Jenna,

    If I understand correctly, Jenna's problem is that the next-button only works after participants have pressed Enter at least once. Of course, the next button should work regardless of whether participants have pressed Enter.

  • I've got the same issue. You can use Ok button only after you press Enter after entering a text in the text_input field. I just instruct my participants to do just that. You can avoid using Ok button, if you return_accepts=yes. Note, however, that participants can simply skip entering anything by pressing enter without providing any input. I remedy this with an inline script that check if any input was provided and prevents the experiment from advancing.
    Hope this helps.

Sign In or Register to comment.