Howdy, Stranger!

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

Supported by

[solved] Change keyboard layout in item text_input

edited January 2014 in OpenSesame

Hi there,
i am using an text_input item, default system language is german.
The question is printed correct (in the sense of german keyboard layout), with characters like ":" and umlaute like "ä". But in the response field, the input is formatted in english keyboard layout, with "z" instead of "y" , ";" instead of "ö" and so on.
Is there a way to change that?
Cheers and Thanks,
Björn

Comments

  • edited 5:50PM

    Hi Björn,

    Right, I'm in Marseille at the moment, and I noticed the same thing with the azerty keyboards. I filed a bug on this: https://github.com/smathot/OpenSesame/issues/86

    The pyscho backend should take your keyboard layout into account. But since the text_input plug-in isn't compatible with the psycho backend at the moment, you'll need a little inline script. You will probably find the code posted in this discussion useful: http://forum.cogsci.nl/index.php?p=/discussion/31/solved-multi-character-keyboard-response-or-simultaneous-sketchpad-and-text_input/p1

    Cheers!
    Sebastiaan

  • edited 5:50PM

    Hey Sebastiaan,

    thank your very much for your response! Unfortunately neither PsychoPy nor the inline code snippet will help me. The inline code snippet indeed is working fine, but i am sorry to say that is not what i was looking for. I am forced to use the legacy backend, since i am also presenting video files with the media player plugin.

    I need to find a way to enable german/Germany keyboard layout inside of the text_input item, because at the moment pressing "z" returns "y", "ö" returns "[" and so on. That is destracting the participants and produces unreadable data ;-)
    Cheers to Marseille from Konstanz! Björn

  • edited 5:50PM

    Right, I see. I can't think of a specific workaround at the moment, but perhaps these pointers could help you a bit with finding a solution yourself.

    Essentially, you will need to find a function that replaces this (from the script linked above):

    resp += my_keyboard.to_chr(key)

    key is a numeric variable that corresponds to the key that is pressed. resp should respond to the equivalent character. But it assumes a Qwerty mapping, so it goes wrong for you. I'm confident that you will be able to find a Python function/ module somewhere that makes an adequate the key → resp translation for different keyboard layouts.

    For more info, see also:

    Should you solve this issue, please let me know!

  • edited 5:50PM

    Hi Sebastiaan,

    thank you very much! At the moment i have found a temporary solution, although not really smart. i added those lines to text_input.py( line 152):

    # QWERTY - Remapping
                elif resp =="z":
                    response += "y"
                elif resp =="y":
                    response += "z" 
                elif resp =="[":
                    response += "ue"
                elif resp ==";":
                    response += "oe"
                elif resp =="'":
                    response += "ae"
                elif resp =="/":
                    response += "-"

    i know that is absoluely unsophistcated, but due time pressure that has to work at the moment.

    wouldn't it be possible to append an wxpython.textframe or wxpython.radiobuttons or something like that to a sketchpad?

    Cheers! Björn

  • edited 5:50PM

    Great. If it works, it works, right?

    Regarding wxWidgets. I believe that wxWidgets requires it's own window to draw on, so you cannot use a PyGame/ PsychoPy window. There might be a hack to make it possible, but you'd have to ask Google.

    If you'd like to use controls, you could also take a look at the source of the questionnaire plug-ins. These come with PGU, which is a GUI toolkit that draws controls using PyGame. It's nowhere near as fancy as wxWidgets though (or Qt4, Gtk3, etc.)

  • edited 5:50PM

    That is absolutely right :-)
    I will ask the mighty google if there is a way to use sketchpad as a panel for wx...
    Thanks! for the hint with the questionnaire plugins, i wasn't aware of their existence by now :-)

  • edited 5:50PM

    i have tried the questionnaire plugin, first impression:great stuff!
    what i am missing is the access to the response variable in the open_question item, though open_question.py seems to collect a response.

  • edited 5:50PM

    Ok, found out some interesting things, i hope i am not disturbing anyone ? :-)

    The questionnaire plugins store their response into a variable called "response". Unfortunately this variable is not called as the "standard" openSesame response variable, such as "response_itemname".

    And, the Variable Inspector locates the corresponding "response" under the name ("in item") of the first item of the respective sequence (e.g. "welcome", so it was a bit tricky to find.

    Furthermore, to log the response of any questionnaire item, one will need a logger item and mark "response".

    To log different responses from different questionnaire plugins within one sequence, you will need to append a logger item directly after every (!) questionnaire plugin. Else, the "response" from questionnaire item no.1 would be overwritten from "response" of questionnaire item no. 2.

    I am happy to add that the open_question item enables QWERTZ (see above)! :-)
    Cheers, Björn

  • edited May 2012

    Thanks for pointing out these issues out! Indeed, these plug-ins don't expose their variables properly. I marked it in the bug tracker: https://github.com/smathot/opensesame_questionnaire_plugins/issues/4

Sign In or Register to comment.