The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
InpuText Input - SDL_KEYDOWN & Chinese Language
maja


Joined: 09 Jul 2016
Posts: 1
I met what I think is a strange bug. I'm following a tutorial on SLD2, everything I write is extremely basic.

My computer is set to Tradiational Chinese with phnetic input by default, every time a new window is opend (as for example a consolle prompt) the user has either to push SHIFT or SHIFT+SPACEBAR to write latin characters.

I have this simple statement for writing text to my console, I also check SDL_KEYDOWN to get the backspaces:

Code:
if(ev.type == SDL_TEXTINPUT || ev.type == SDL_KEYDOWN) {
    system("cls");
    if(ev.type == SDL_KEYDOWN && ev.key.keysym.sym == SDLK_BACKSPACE && text.length() > 0) {
        text = text.substr(0, text.length() - 1);
    }
    else {
         text += ev.text.text;
    }
    std::cout << text << std::endl;
}

Adding ev.type == SDL_KEYDOWN to the code results in all characters being written as subscript of the following gibberish character:

Most probably this has no influence at all on practical applications, still it's a curious thing.