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
break next/current SDL_TEXTINPUT on dead key
albert


Joined: 22 Oct 2009
Posts: 29
Hi,

My use case:

The user can setup any key as the key to show/hide the ingame drop-down console. A common key is the dead key "^".
I also use SDL_TEXTINPUT at some places, e.g. the ingame console itself. Now, on certain SDL_KEYDOWN events which I handle (like the console key "^"), I don't want that it gets into any SDL_TEXTINPUT.

Can I somehow reset any current text input?

In case it is not a dead key, I also get the SDL_TEXTINPUT event right away and my current solution works fine: Ignore any SDL_TEXTINPUT when I got such SDL_KEYDOWN.

If it is a dead key, I don't know how I can handle that. The next key should be handled for the text input as if the dead key was not pressed before.

Earlier in SDL1, when I handled all of this manually in SDL_KEYDOWN, it was not a problem to handle this case.

Any advice?

Thanks,
Albert
break next/current SDL_TEXTINPUT on dead key
eric.w


Joined: 12 Feb 2014
Posts: 38
Hi,

I just did this in quakespasm, borrowing the idea from ioquake3. The hack is, just ignore any SDL_TEXTINPUT event that arrives between a SDL_KEYDOWN for the key that’s supposed to open the console, and the next SDL_KEYUP (e.g. by setting a flag when you get the SDL_KEYDOWN that opens the console, and clearing it on the next SDL_KEYUP).


It’s a tricky problem, and I couldn’t think of a good solution when first porting quakespasm to SDL2. I’m not sure if you can really do better than this; it seems to me that a more robust solution would have to involve the SDL_TEXTINPUT event telling you that it was generated from a particular SDL_KEYDOWN, so your application code could match up the events and know to ignore the SDL_TEXTINPUT for that character.


Here’s our sdl input code: http://sourceforge.net/p/quakespasm/code/1020/tree//trunk/quakespasm/Quake/in_sdl.c#l522


Cheers
Eric

On Sep 10, 2014, at 8:43 AM, albert wrote:
Quote:
Hi,

My use case:

The user can setup any key as the key to show/hide the ingame drop-down console. A common key is the dead key "^".
I also use SDL_TEXTINPUT at some places, e.g. the ingame console itself. Now, on certain SDL_KEYDOWN events which I handle (like the console key "^"), I don't want that it gets into any SDL_TEXTINPUT.

Can I somehow reset any current text input?

In case it is not a dead key, I also get the SDL_TEXTINPUT event right away and my current solution works fine: Ignore any SDL_TEXTINPUT when I got such SDL_KEYDOWN.

If it is a dead key, I don't know how I can handle that. The next key should be handled for the text input as if the dead key was not pressed before.

Earlier in SDL1, when I handled all of this manually in SDL_KEYDOWN, it was not a problem to handle this case.

Any advice?

Thanks,
Albert
_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org