Howdy, Stranger!

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

Supported by

[open] Farsi text input

edited July 2013 in OpenSesame

Hi
Can I change the script so the program accepts Farsi text input which is right to left?

Thanks,
Masoud

Comments

  • edited 12:10AM

    Hi Masoud,

    For text input the situation is pretty much the same as for text output. It can be done, but it requires inline scripting. Below you see simple script, adapted from this discussion, that gives a very simple example of how you can implement right-to-left text input.

    For more information, see the code comments in the script and these documentation pages:


    from openexp.canvas import canvas
    from openexp.keyboard import keyboard
    
    my_canvas = canvas(exp)
    my_keyboard = keyboard(exp)
    
    resp = u'' # Here we store the response
    
    # Start with a clean canvas
    my_canvas.clear()
    my_canvas.text(resp)
    my_canvas.show()    
    
    while True:
        # Get a keyboard response
        key, time = my_keyboard.get_key()
        # If return is pressed the loop should be exited.
        if key == u'return':
            break           
        # Handle backspace by removing the last character
        if key == u'backspace':
            resp = resp[1:]
        else:
            # Convert 'space' to a space character. Other
            # characters can be recoded in the same way.
            if key == u'space':
                key = u' '
            resp = key + resp
    
        # Show the canvas
        my_canvas.clear()
        my_canvas.text(resp)
        my_canvas.show()
    
    # Save the response
    self.experiment.set('response', resp)
    

    Cheers!
    Sebastiaan

    There's much bigger issues in the world, I know. But I first have to take care of the world I know.
    cogsci.nl/smathot

  • edited 12:10AM

    Dear Sebastiaan
    Thanks for the information. I am just want to add to my question that the program needs to wait 30 seconds then the participants can write all of the words they can, so the target response isn't a single key. Does this make any difference in the inline_script?
    Masoud

  • edited 12:10AM

    The script collects a string of text input until the participant presses return. So I imagine that's what you need. If you want to add a 30 s pause to your experiment, you can simply insert an advanced_delay item (or some other item that introduces a pause) before the inline script.

    Cheers,
    Sebastiaan

    There's much bigger issues in the world, I know. But I first have to take care of the world I know.
    cogsci.nl/smathot

Sign In or Register to comment.