TextInput in form, auto focus
in OpenSesame
Hi,
I'm building an experiment with Open sesame. In this experiment, I use a form and the widget TextInput (with inline script Python) so participants can write their responses.
Currently, the participant has to click in the frame before to write his response. I would like to be allowed to write the answer without this click (directly when this form displays itself). How can I force the focus ?
Thanks you for your help!
NB: I'm using the backend "PsychoPy, powerful stimulusgeneration"
Comments
Hi @Ines_,
Not sure how your code is implemented but check that you have included "focus=yes" in the setting of the text_input widget:
For example:
widget 0 2 1 1 text_input focus=yes return_accepts=yes stub="" var="[form_var]"If you didn't have this, I believe it might solve your problem.
Best,
Fabrice.
Hi,
Thank you for your answer.
Actually, I tried:
However, I have this error message:
TypeError: __init__() got an unexpected keyword argument 'focus'
Inès
Hey @Fab
Your solution maybe work using OpenSesameScript, but do you have any clues about using this with a Python inline script ?
Best regards,
Inès
Hi @Ines_,
I'm no expert with the forms/Python, but if you upload a basic working example with your form, I can take a look and see if I can come up with something.
Best,
Fabrice.
Hi,
Thank you for your answer!
I'm adding an Opensesame file with the form. It's a form with textInput to enable participants to write their answers (names of items to remember in different positions in a list). They have to write lots of answers. Thus, it isn't ergonomic to have to click in the frame before to write.
Best regards,
Inès
Hi @Ines_,
I poked around a little but no luck so far. As far as I can tell, the system's focus seems to be out of the whole task window, as if you press ESC when one the second screen (
Response_part), OS does not register it until you click on the window.Even though you're not using Tkinter, one solution (https://forum.cogsci.nl/discussion/5172/problem-using-tkinter-interface) solves that latter problem - the window does appear to regain focus - , but I couldn't find a way to force the focus to a specific widget in Python. From what I read on the web, I think that using Tkinter to set up your form might make it easier (Tkinter objects appear to take a
.focus()property), though it can bring its own focus issuesI don't know enough about Python and the implementation of the widgets in OS to solve this one, but have you considered using the built-in form objects instead of creating it from Python? This would make the issue simpler as you'd just be able to use
focus=yesoption.Alternatively, the solution proposed here might also be an option, as it offers a way to create the widgets and emulate a mouse click on a specific object: https://forum.cogsci.nl/discussion/447/open-form-enter-button.
Hope these pointers can be of help.
Fabrice.
Hi @Fab,
Thank you very much for your elaborate answer!
It was very usefull and it enabled me to resolve my issue.
Thank you!
Best,
Inès