SFML community forums

Help => Graphics => Topic started by: iride on February 09, 2018, 06:43:22 am

Title: Can't directly type Korean
Post by: iride on February 09, 2018, 06:43:22 am
Hi,
Whenver I type in Korean,I don't receive TextEntered events right away.
Instead a small popup appears and I must first type the text on that popup window and press enter to receive the events.
This makes it very frustrating to type.
How can I get rid of this??

I'm on windows 10, sfml 2.4.2.
Title: Re: Can't directly type Korean
Post by: Laurent on February 09, 2018, 08:45:58 am
I'm not sure this is directly related to SFML. Does this happen only with SFML apps? Can you show a minimal code that reproduces the problem?
Title: Re: Can't directly type Korean
Post by: eXpl0it3r on February 09, 2018, 11:30:51 am
Do you use IME?
Title: Re: Can't directly type Korean
Post by: FRex on February 09, 2018, 11:54:45 am
This is how many (most?) CJK IMEs work and it's their intended way of working:  https://en.wikipedia.org/wiki/Input_method

If this happens in SFML then it has to be happening in all other apps too unless they forcibly turn IME off somehow, like via: https://msdn.microsoft.com/en-us/library/windows/desktop/dd318171(v=vs.85).aspx

If you don't want the pop ups then there are keyboard layouts you can turn on but I don't know Korean so I don't know if they get rid of the pop up:
Title: Re: Can't directly type Korean
Post by: iride on February 09, 2018, 03:28:35 pm
I'm not sure this is directly related to SFML. Does this happen only with SFML apps? Can you show a minimal code that reproduces the problem?
I think this happens only with SFML apps. It doesn't happen with Google Chrome, MS word, Overwatch, etc.

int main()
{
sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");

while (window.isOpen())
{
        sf::Event event;
        while (window.pollEvent(event))
        {
                if (event.type == sf::Event::Closed)
                        window.close();
                if (event.type == sf::Event::TextEntered)
                {
                        std::cout << event.text.unicode << "\n";
                }
        }

        window.clear();
        window.display();
}
}
Do you use IME?
Yes, I'm using Microsoft IME for Korean.

This is how many (most?) CJK IMEs work and it's their intended way of working:  https://en.wikipedia.org/wiki/Input_method

If this happens in SFML then it has to be happening in all other apps too unless they forcibly turn IME off somehow, like via: https://msdn.microsoft.com/en-us/library/windows/desktop/dd318171(v=vs.85).aspx

If you don't want the pop ups then there are keyboard layouts you can turn on but I don't know Korean so I don't know if they get rid of the pop up:
  • https://lovingkorean.com/2016/01/13/how-to-change-keyboard-language-in-windows-10-to-korean/
  • https://en.wikipedia.org/wiki/Korean_language_and_computers

I can't type in Korean at all if I call ImmAssociateContext(handle, nullptr)
Title: Re: Can't directly type Korean
Post by: FRex on February 09, 2018, 05:13:43 pm
How do other apps do it then? The only difference I can think of is that they display the text you're inputting with IME inline (but I still think it's not processed right away, like if you type something into http://translate.google.com/ it will only translate after you press enter) where it should be where SFML shows a pop up in the top left corner.
Title: Re: Can't directly type Korean
Post by: iride on February 09, 2018, 06:59:48 pm
Other apps immediate display the Korean alphabets.
Like for example
Typing in notepad:
https://www.youtube.com/watch?v=aW9TNp8FpZo
Typing in SFML app
https://www.youtube.com/watch?v=FQKOB12_Gi8
Title: Re: Can't directly type Korean
Post by: iride on February 09, 2018, 08:12:31 pm
I think this question might be related:
https://stackoverflow.com/questions/434048/how-do-you-use-ime

From looking at this question, I think it might be impossible to do what I want with SFML.
I looked at SDL and it seems that SDL has what I want.
https://wiki.libsdl.org/Tutorials/TextInput
Title: Re: Can't directly type Korean
Post by: FRex on February 09, 2018, 09:57:29 pm
The way I understand it it's not 'direct typing' and it just lets the application see what the user has in the IME during the composition and handle the drawing. The SDL example considers only committed input to be part of the text.

Yes, SFML is not catching these WM_IME_ events right now but if it did these would be some other kind of event, not TextEntered and you'd have to handle it specially in the app itself to show the preview.
Title: Re: Can't directly type Korean
Post by: eXpl0it3r on February 09, 2018, 10:47:05 pm
I recently looked through SDL's code and noticed that someone once must have done some ugly reverse engineering to implement their IME support... I mean look at this (https://github.com/SDL-mirror/SDL/blob/master/src/video/windows/SDL_windowskeyboard.c#L473). ;D

Not sure if it's really worth investing time into this, but it's certainly not something that will be highly prioritized. Of course every contribution is welcome. ;)