Text input without mouseclick + key restrictions for text input
Hello,
I am planning an experiment with a text input and have a few problems I can't overcome. A short summary for the procedure:
People receive two statements about objects (e.g. The apple left of the pear; The Banana is right of the pear). After reading the statments they shall write the first letter of each oject in one text file.
Lets say the solution is Apple Pear Banana. They have to type A P B.
Now.. there are always two correct possibilities (revision_ro and revision_lo) and all other are wrong. I want the two correct onces to be coded sperately because it serves important information. I made a python script like this:
from libopensesame import widgets
form = widgets.form(exp)
text_input = widgets.text_input(form, stub = 'Schreibe hier.. ', center=True, frame = True, var='user_input',
return_accepts=True)
form.set_widget(text_input, (0,0))
form._exec(focus_widget=None)
if var.user_input == var.revision_lo:
var.correctness = 1
elif var.user_input == var.revision_ro:
var.correctness = 2
else:
var.correctness = 0
print(var.user_input)
print(var.revision_lo)
print(var.revision_ro)
print(var.correctness)
This script works, but:
1. Participants always have to click into the text field before they can start writing. Is there a way to change this? Because of this my reaction times vary way to much
2. is there a way to restrict the input keys? I only want them to type letters like A P B. No numbers, or other stuff
Greetings,
Andreas
Comments
Hi Andreas,
Yes, you can specify a
focus_widget
inform.exec_()
. So in your case that would be:Not in OpenSesame 3.1 and earlier. But you can do this in OpenSesame 3.2, which is now in prerelease (but almost ready for stable release). So I would grab the latest 3.2.0 prerelease, and take a look at the new form-validation options:
Cheers!
Sebastiaan
Check out SigmundAI.eu for our OpenSesame AI assistant!
Sebastiaan! Thanks alot! This was way easier than I thought Maybe you can help me out with another issue:
My experiment runs on two screens (sometimes the stuff shows up on the left screen, sometimes on the right). I set the experiment to 3840x1080p and I can define the coordinates for pictures etc. in the script tab. But I dont know how to do it for my python inline script (see above). It should appear 50% of the time on the left and 50% on the right screen. If this is too complicated.. It would be ok to duplicate it.. so the same text input shows on both screens, but you only need to fill out one (without mirroring the screen via windows)
Cheers,
Andreas
Ok I'm facing another problem with the filter ..
Participants should be allowed to type only ABC as letters and if they make mistakes they can use "backspace" to delete the letter. If they are finished they should press "return" to confirm.
If I set:
They can also type "r, s, n, etc." because this letters are included in "return" and "backspace"... Is there a way to fix this?
Another point.. The Focus works great, but: The cursor always appears.. Is there a way to hide the mouse cursor?
Sorry but I am totally new to python
Greetings,
Andreas
You're providing a string, which is effectively a list of individual characters. The backspace and return keys are not individual characters, but rather multicharacter strings themselves. So you need to check against a list of keys, like so:
You can if you really want to, but this requires monkey-patching the internals of OpenSesame to override
showing the cursor at all. So it's not something that I would recommend.
Below you see how you can do this. But this disables the mouse cursor in general, not just for the form!
Check out SigmundAI.eu for our OpenSesame AI assistant!