Howdy, Stranger!

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

Supported by

[open] Form - enter button

edited May 2013 in OpenSesame

I'm trying to create a form in open sesame that is a question with three answer boxes. using the code bellow, to get from the first box to the second you have to press enter, then click the second box, type your response, press enter, click on the third box, type your answer, press enter, click next to move onto the next page. there is also a submit button, and if i make the accepts="yes" rather than no, pressing enter on that response moves onto the next page, which would be fine for the third question, but doesn't allow subjects to respond to the first two questions. we need to know the total time that the subject spends to answer all three questions

Ideally, I'd want to let subjects be able to move to the next box by clicking the tab button, or just having access to their mouse, because the enter then click thing is really annoying. Let me know if this is possible!


set margins "50;100;50;100"
set rows "1;1;1;1;1"
set spacing "20"
set cols "1;1;1"
set description "A generic form plug-in"
widget 0 0 3 1 label center="no" text="What were the [Target_Color] words?"
widget 0 1 1 1 text_input return_accepts="no" var="Word_01_Response"
widget 0 2 1 1 text_input return_accepts="no" var="Word_02_Response"
widget 0 3 1 1 text_input return_accepts="no" var="Word_03_Response"
widget 2 4 1 1 button text="Next"

Comments

  • edited 12:30PM

    ITA

    We will come back to you as soon as possible!

    Buy Me A Coffee

  • edited May 2013

    Hi,

    Sorry for the delay.

    There is also a submit button, and if I make the accepts="yes" rather than no, pressing enter on that response moves onto the next page, which would be fine for the third question, but doesn't allow subjects to respond to the first two.

    There is a trick to use this keyword argument to obtain the desired behaviour, namely a form in which the participant can go to the next box without having to make any mouse clicks.

    This works as follows. Instead of creating one form_base item, we wrap a loop item around three form_base items with a slightly OpenSesame script. (Still, for the participant this will look as one form.)

    More specifically:

    Firstly, create an experiment with an overview that looks something like this:

    image

    Secondly, enter the following scripts into the three form_base items (please see the comments for further explanation).

    form_base1: For the first text_input widget, set focus to 'yes', and set return_accepts to 'yes'. focus = 'yes' indicates that the participant can start typing in this box immediately (without having to click in it first). Don't specify anything yet for the other widgets yet (just draw them).

    set margins "50;100;50;100"
    set rows "1;1;1;1;1"
    set spacing "20"
    set cols "1;1;1"
    set description "A generic form plug-in"
    widget 0 0 3 1 label center="no" text="What were the [Target_Color] words?"
    widget 0 1 1 1 text_input focus="yes" return_accepts="yes" var="Word_01_Response"
    widget 0 2 1 1 text_input
    widget 0 3 1 1 text_input
    

    form_base2: For the second form_base, set focus and return_accepts to "yes" for the second text_input widget. For the first text_input widget, set the text to "Word_01_Response" (to keep the previously-given response on screen).

    set margins "50;100;50;100"
    set rows "1;1;1;1;1"
    set spacing "20"
    set cols "1;1;1"
    set description "A generic form plug-in"
    widget 0 0 3 1 label center="no" text="What were the [Target_Color] words?"
    widget 0 1 1 1 text_input text="[Word_01_Response]"
    widget 0 2 1 1 text_input focus="yes" return_accepts="yes" var="Word_02_Response"
    widget 0 3 1 1 text_input
    

    form_base3: For the last form_base item, fill both previous text input widgets with the given responses and set focus and return_accepts to 'yes' for the last item.

    set margins "50;100;50;100"
    set rows "1;1;1;1;1"
    set spacing "20"
    set cols "1;1;1"
    set description "A generic form plug-in"
    widget 0 0 3 1 label center="no" text="What were the [Target_Color] words?"
    widget 0 1 1 1 text_input text="[Word_01_Response]"
    widget 0 2 1 1 text_input text="[Word_02_Response]"
    widget 0 3 1 1 text_input focus="yes" return_accepts="yes" var="Word_03_Response"
    

    I uploaded a working example experiment here (download, change the extension from '.txt' into '.opensesame' and open as normally).

    I hope this helps! If you have any more questions, don't hesitate to ask them!

    Best,

    Lotje

    Buy Me A Coffee

  • edited June 2013

    Hi Lotje,

    Thanks so much for your help, it is so much better now! One question I can't figure out now is whether or not I can disable the tab function. As it is now, when participants press tab to go to the next box rather than return, the mouse appears and it is very hard to advance to the next page. It seems to work if I click on the first box and retype their answers, but if there is a way to just disable mouse/tab options completely that would be much easier.

    Thanks!

    Margaret

  • edited 12:30PM

    Sorry for the wait, I'll get back to you soon. ITA

    Buy Me A Coffee

  • edited June 2013

    Hi Margaret,

    The fact that pressing Tab defocuses a widget is built-in to the forms. The easiest way to nevertheless get the behavior that you need is probably to take control of the form widgets more directly. The script below implements the form described above in Python inline script.

    Essentially, the script doesn't run the form as a whole, but selectively activates the three text_input widgets. Normally, a form would show a mouse when you press Tab while in a text_input, but the script shown below will simply advance to the next widget when Tab is pressed. The script is explained in more detail in the code comments.

    This approach is more complicated than using the form_base plug-in, but it offers more flexibility. Also, it allows you to pack the whole form into one script, insteed of three separate items.

    For more information, see also:


    # Import the widgets library
    from libopensesame import widgets
    
    # Create a form
    form = widgets.form(self.experiment, cols=[1,1,1], rows=[1,1,1,1,1],
        margins=(50,100,50,100), spacing=20)
    
    # Create widgets
    question_text = 'What were the %s words?' % self.get('targetColor')
    question_label = widgets.label(form, text=question_text)
    input1 = widgets.text_input(form, return_accepts=True, var='Word_01_Response')
    input2 = widgets.text_input(form, return_accepts=True, var='Word_02_Response')
    input3 = widgets.text_input(form, return_accepts=True, var='Word_03_Response')
    
    # Add the widgets to the form.
    form.set_widget(question_label, (0,0), colspan=3)
    form.set_widget(input1, (0,1))
    form.set_widget(input2, (0,2))
    form.set_widget(input3, (0,3))
    
    # Reset the variables!
    exp.set('Word_01_Response', '')
    exp.set('Word_02_Response', '')
    exp.set('Word_03_Response', '')
    
    # Bypass the form, and activate the input widgets directly, by mimicking
    # mouse clicks. Pressing either tab or return will advance to the next widget.
    input1.on_mouse_click((0,0))
    input2.on_mouse_click((0,0))
    input3.on_mouse_click((0,0))
    
    # Optionally, you can give the user a second chance to fill in missed fields
    check = True # Set to False to deactivate checking
    if check and self.get('Word_01_Response') == '':
        input1.on_mouse_click((0,0))
    if check and self.get('Word_02_Response') == '':
        input2.on_mouse_click((0,0))
    if check and self.get('Word_03_Response') == '':
        input3.on_mouse_click((0,0))
    

    Cheers!
    Sebastiaan

    Buy Me A Coffee

Sign In or Register to comment.

agen judi bola , sportbook, casino, togel, number game, singapore, tangkas, basket, slot, poker, dominoqq, agen bola. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 50.000 ,- bonus cashback hingga 10% , diskon togel hingga 66% bisa bermain di android dan IOS kapanpun dan dimana pun. poker , bandarq , aduq, domino qq , dominobet. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 10.000 ,- bonus turnover 0.5% dan bonus referral 20%. Bonus - bonus yang dihadirkan bisa terbilang cukup tinggi dan memuaskan, anda hanya perlu memasang pada situs yang memberikan bursa pasaran terbaik yaitu http://45.77.173.118/ Bola168. Situs penyedia segala jenis permainan poker online kini semakin banyak ditemukan di Internet, salah satunya TahunQQ merupakan situs Agen Judi Domino66 Dan BandarQ Terpercaya yang mampu memberikan banyak provit bagi bettornya. Permainan Yang Di Sediakan Dewi365 Juga sangat banyak Dan menarik dan Peluang untuk memenangkan Taruhan Judi online ini juga sangat mudah . Mainkan Segera Taruhan Sportbook anda bersama Agen Judi Bola Bersama Dewi365 Kemenangan Anda Berapa pun akan Terbayarkan. Tersedia 9 macam permainan seru yang bisa kamu mainkan hanya di dalam 1 ID saja. Permainan seru yang tersedia seperti Poker, Domino QQ Dan juga BandarQ Online. Semuanya tersedia lengkap hanya di ABGQQ. Situs ABGQQ sangat mudah dimenangkan, kamu juga akan mendapatkan mega bonus dan setiap pemain berhak mendapatkan cashback mingguan. ABGQQ juga telah diakui sebagai Bandar Domino Online yang menjamin sistem FAIR PLAY disetiap permainan yang bisa dimainkan dengan deposit minimal hanya Rp.25.000. DEWI365 adalah Bandar Judi Bola Terpercaya & resmi dan terpercaya di indonesia. Situs judi bola ini menyediakan fasilitas bagi anda untuk dapat bermain memainkan permainan judi bola. Didalam situs ini memiliki berbagai permainan taruhan bola terlengkap seperti Sbobet, yang membuat DEWI365 menjadi situs judi bola terbaik dan terpercaya di Indonesia. Tentunya sebagai situs yang bertugas sebagai Bandar Poker Online pastinya akan berusaha untuk menjaga semua informasi dan keamanan yang terdapat di POKERQQ13. Kotakqq adalah situs Judi Poker Online Terpercayayang menyediakan 9 jenis permainan sakong online, dominoqq, domino99, bandarq, bandar ceme, aduq, poker online, bandar poker, balak66, perang baccarat, dan capsa susun. Dengan minimal deposit withdraw 15.000 Anda sudah bisa memainkan semua permaina pkv games di situs kami. Jackpot besar,Win rate tinggi, Fair play, PKV Games