Select text_input on form execution
I have a form page with a label and a text input box below, created with python script. I would like for the text input box to be automatically selected when the form appears so that the participant will only have to type the response and press enter without having to use the mouse.
I tried using textbox.on_mouse_click, which automatically allows the participant to begin typing in the box, but does not register when the 'enter' key is pressed (I still have to click on the text box again and then press enter).
Does anyone know how to solve this problem? Sorry if this question has been asked before. Thank you for your help!
Comments
Hi tsummer2,
In the ready-made plugin form_text_input the text_input widget has a keyword
focus=yes. Possibly this also works for your form. Or maybe you can use the ready-made plugin form_text_input?Best,
Jarik
I figured it out.
The _exec function of a form has an argument for determining which widget to focus on. By default it is None. Here is the code for selecting my text_input widget when the form is loaded:
execform = form._exec(focus_widget=textbox)
Ah perfect. Thanks for sharing! It is indeed reported here: