How to do input Chinese with handwriting?

When input Chinese with handwriting, once stroke one, SDL will generate a
KEY-event with SDLK_BACKSPACE. To repsponse this event, application will
delete a character back. But in fact, this delete is excrescent and will
result error.

On the other hand, press BASKSPACE on keyboard also generate a KEY-event
with SDLK_BACKSPACE!

When receive SDLK_BACKSPACE, application can not distinguish whether should
delete or not.

You should use text input events instead of “raw” key up/down events.
For more information, see:
http://wiki.libsdl.org/moin.fcg/Tutorials/TextInputOn 01.07.2013 17:49, li zhuo wrote:

When input Chinese with handwriting, once stroke one, SDL will generate a
KEY-event with SDLK_BACKSPACE. To repsponse this event, application will
delete a character back. But in fact, this delete is excrescent and will
result error.

On the other hand, press BASKSPACE on keyboard also generate a KEY-event
with SDLK_BACKSPACE!

When receive SDLK_BACKSPACE, application can not distinguish whether should
delete or not.

Yes, I use both key up/down and text input in my code on misc OS (Windows,
iOS etc). It will receive ASCII key by key up/down, include backspace, and
unicode character by text input, for example Chinese.

Input Chinese with handwriting on iOS, Chinese is received by text input.
But I must use key up/down in order to receive ASCII, and will receive
backspace once stroke one duration touch!

Yes, I use both key up/down and text input in my code on misc OS (Windows,
iOS etc). It will receive ASCII key by key up/down, include backspace, and
unicode character by text input, for example Chinese.

Input Chinese with handwriting on iOS, Chinese is received by text input.
But I must use key up/down in order to receive ASCII, and will receive
backspace once stroke one duration touch!> ----- Original Message -----

From: sdl-bounces@lists.libsdl.org [mailto:sdl-bounces at lists.libsdl.org] On
Behalf Of Jannik Heller
Sent: Monday, July 01, 2013 11:53 PM
To: SDL Development List
Subject: Re: [SDL] How to do input Chinese with handwriting?

You should use text input events instead of “raw” key up/down events.
For more information, see:
http://wiki.libsdl.org/moin.fcg/Tutorials/TextInput


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Yes, I use both key up/down and text input in my code on misc OS (Windows,
iOS etc). It will receive ASCII key by key up/down, include backspace, and
unicode character by text input, for example Chinese.

Input Chinese with handwriting on iOS, Chinese is received by text input.
But I must use key up/down in order to receive ASCII, and will receive
backspace once stroke one duration touch!

I have a related (though less serious) problem. SDL decides itself
what is text and what is not, but it doesn’t agree with me.

In my editor, it thinks numeric keypad keys are text, but for
me they’re always arrow keys. So I have to put a flag to
ignore the text input events.

The problem here is that I rely on the sequence:

(a) key PRESS
(b) text input
(c) repeat above
(d) key RELEASE

and in practice on the horrible mess that is a PC keyboard this does NOT
happen if you press two keys together (i.e. you have key rollover).

Similarly, SDL decides what mod keys are there and also stuff like
whether NUM/CAPS lock work.

Ideally if a keypress generates text it should go in the keypress event,
not a separate event. Relying on sequencing event streams is a bad
idea. however I can see why these are split (other input devices
like software keypads on a phone).On 02/07/2013, at 9:01 AM, li zhuo wrote:


john skaller
@john_skaller
http://felix-lang.org

2013/7/1, john skaller :

Ideally if a keypress generates text it should go in the keypress event,
not a separate event. Relying on sequencing event streams is a bad
idea. however I can see why these are split (other input devices
like software keypads on a phone).

I think the main issue is IME (and the like), where a key press is not
directly tied to a character, and moreover, they won’t send individual
characters, but entire words at once (or even entire phrases).

2013/7/1, john skaller <@john_skaller>:

Ideally if a keypress generates text it should go in the keypress event,
not a separate event. Relying on sequencing event streams is a bad
idea. however I can see why these are split (other input devices
like software keypads on a phone).

I think the main issue is IME (and the like), where a key press is not
directly tied to a character, and moreover, they won’t send individual
characters, but entire words at once (or even entire phrases).

Sure, this is the case even on a PC keyboard: key “A” can generate
either upper or lower case “a”.

however I’m confused: in my editor (desktop, PC KB) I am using
SDL_TEXTINPUT to get ASCII. Doesn’t this work on iOS?

And why is SDLK_BACKSPACE sent when doing Chinese input?On 02/07/2013, at 11:21 AM, Sik the hedgehog wrote:


john skaller
@john_skaller
http://felix-lang.org

2013/7/1, john skaller :

Sure, this is the case even on a PC keyboard: key “A” can generate
either upper or lower case “a”.

But that’s a single character, the problem is that you can end up
receiving an entire string of characters (for example, in Japanese I
can type “ogenkidesuka” and get “???” entered all
at once).

however I’m confused: in my editor (desktop, PC KB) I am using
SDL_TEXTINPUT to get ASCII. Doesn’t this work on iOS?

No idea (I don’t program on iOS), but it should. If it doesn’t then
that sounds like it could be a bug :confused:

And why is SDLK_BACKSPACE sent when doing Chinese input?

If that event is sent during typing (i.e. in the middle of writing a
set of characters), that’s probably a bug, SDL shouldn’t really send
that kind of events while text input is enabled (leaving
SDLK_BACKSPACE to be received only if you aren’t already typing
something).

And why is SDLK_BACKSPACE sent when doing Chinese input?=================================
On Windows, SDLK_BACKSPACE isn’t sent duration Chinese input, so let key down/up recieve ASCII and text input receive UNICODE, that is fine!

But on iOS, SDLK_BACKSPACE is sent duration Chinese input, one stroke one sent. I track into code, one stroke will triger below shouldChangeCharacersInRange, and satisfy “[string length] == 0”, so SDL will send a SDLK_BACKSPACE. Hit me up, press BACKSPACE on keyboard also enter it, so when receive SDLK_BACKSPACE, application can not distinguish whether should delete or not.

  • (BOOL)textField:(UITextField *)_textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString )string
    {
    if ([string length] == 0) {
    /
    it wants to replace text with nothing, ie a delete */
    SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_DELETE);
    SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_DELETE);
    }
    else {

    }

    }

Can’t the text input api be used to detect deleting text? I.e. if there
is a text input event with ascii code 8 (control character, backspace),
react to that, and ignore key up/down events.On 02.07.2013 16:59, li zhuo wrote:

And why is SDLK_BACKSPACE sent when doing Chinese input?

On Windows, SDLK_BACKSPACE isn’t sent duration Chinese input, so let key down/up recieve ASCII and text input receive UNICODE, that is fine!

But on iOS, SDLK_BACKSPACE is sent duration Chinese input, one stroke one sent. I track into code, one stroke will triger below shouldChangeCharacersInRange, and satisfy “[string length] == 0”, so SDL will send a SDLK_BACKSPACE. Hit me up, press BACKSPACE on keyboard also enter it, so when receive SDLK_BACKSPACE, application can not distinguish whether should delete or not.

  • (BOOL)textField:(UITextField *)_textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString )string
    {
    if ([string length] == 0) {
    /
    it wants to replace text with nothing, ie a delete */
    SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_DELETE);
    SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_DELETE);
    }
    else {

    }

    }

SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

It looks like what he describes is that the backspace event is sent if
it empties the string being input, when it should do it only when it
isn’t already in input mode for starters. Am I getting it right?

2013/7/2, Jannik Heller :> Can’t the text input api be used to detect deleting text? I.e. if there

is a text input event with ascii code 8 (control character, backspace),
react to that, and ignore key up/down events.

On 02.07.2013 16:59, li zhuo wrote:

And why is SDLK_BACKSPACE sent when doing Chinese input?

On Windows, SDLK_BACKSPACE isn’t sent duration Chinese input, so let key
down/up recieve ASCII and text input receive UNICODE, that is fine!

But on iOS, SDLK_BACKSPACE is sent duration Chinese input, one stroke one
sent. I track into code, one stroke will triger below
shouldChangeCharacersInRange, and satisfy “[string length] == 0”, so SDL
will send a SDLK_BACKSPACE. Hit me up, press BACKSPACE on keyboard also
enter it, so when receive SDLK_BACKSPACE, application can not distinguish
whether should delete or not.

  • (BOOL)textField:(UITextField *)_textField
    shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString
    )string
    {
    if ([string length] == 0) {
    /
    it wants to replace text with nothing, ie a delete */
    SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_DELETE);
    SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_DELETE);
    }
    else {

    }

    }

SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org