Howdy, Stranger!

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

Supported by

Text input without mouseclick + key restrictions for text input

edited January 2018 in OpenSesame

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,

    Participants always have to click into the text field before they can start writing. Is there a way to change this?

    Yes, you can specify a focus_widget in form.exec_(). So in your case that would be:

    form._exec(focus_widget=text_input)
    

    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

    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

  • 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:

    def filter_letters(ch):
    
        """Allows only letters"""
    
        return ch in u'abc backspace return' 
    

    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

  • They can also type "r, s, n, etc." because this letters are included in "return" and "backspace"... Is there a way to fix this? :)

    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:

    def filter_letters(ch):
    
        return ch in ['a', 'b', 'c', 'backspace', 'return']
    

    Another point.. The Focus works great, but: The cursor always appears.. Is there a way to hide the mouse cursor?

    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!

    def invisible_get_click(get_click):
    
        def inner(self, **resp_args):
    
            if 'visible' in resp_args:
                del resp_args['visible']
            return get_click(self, **resp_args)
    
        return inner
    
    
    # Get the backend-specific class of the Mouse object, and monkey-patch it by
    # replacing get_click() and show_cursor(). The former needs is decorated with a
    # function that strips the visible argument. The latter is just replaced by a
    # dummy function.
    mouse_class = Mouse().__class__
    mouse_class.get_click = invisible_get_click(mouse_class.get_click)
    mouse_class.show_cursor = lambda show: None
    
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