Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Android text input other than english  (Read 3598 times)

0 Members and 2 Guests are viewing this topic.

wdmitry

  • Newbie
  • *
  • Posts: 17
    • View Profile
Android text input other than english
« on: June 11, 2024, 11:39:58 pm »
the event _ev.type == sf::Event::TextEntered won't come on input attempt in another language.
the button code comes -1.

however in desktop version it works

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: Android text input other than english
« Reply #1 on: June 12, 2024, 09:13:00 am »
So you're saying if you use a different keyboard layout you're not getting any TextEntered events?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

wdmitry

  • Newbie
  • *
  • Posts: 17
    • View Profile
Re: Android text input other than english
« Reply #2 on: June 12, 2024, 09:32:17 am »
seems like. if layout is eng, I get textEntered event.
but when I change layout, it only detects KeyReleased with code -1

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: Android text input other than english
« Reply #3 on: June 12, 2024, 01:22:10 pm »
You seem to be mixing things now, which makes it unclear to me what the issue is exactly, what you're expecting and what is actual happening.

TextEntered has nothing to do with KeyPressed or KeyReleased, those are different events.

I just had someone else confirm on their end, that with a different layout (with Gboard) the TextEntered event works as expected.
So you're not getting a TextEntered event?
See here how to correctly handle that event type: https://www.sfml-dev.org/tutorials/2.6/window-events.php#the-textentered-event

What keyboard layout are you using?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

wdmitry

  • Newbie
  • *
  • Posts: 17
    • View Profile
Re: Android text input other than english
« Reply #4 on: June 12, 2024, 08:49:23 pm »
I can post the code a little later.

What I mean that I don't get textEntered event in other layouts if the letter is not present in english asci code.
Chinese/Arabic/Cyrillic

But it works if I compile for desktop. So I assumed the issue has to be with Android.

***

So here I see if the event is from Keyboard.
On Ubuntu on non english layout I get
sf::Event::TextEntered  event with correct unicode that I can parse into right letter.

On Android on non english layout I get
sf::Event::KeyReleased event with _ev.key.code = -1, if I press any of non latin symbols.
so if the layout still has some latin chars like "abcde" all works, but if I press any of "абвгд" it will only trigger KeyReleased.

void TextInput::OnSFMLEvent(sf::Event const& _ev)
{
    if (_ev.type == sf::Event::KeyReleased)
    {
         *** handle Enter / Backspace ***
    }
    else if (_ev.type == sf::Event::TextEntered)
    {
         *** handle unicode ***
    }
}
 
« Last Edit: June 12, 2024, 10:29:46 pm by wdmitry »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: Android text input other than english
« Reply #5 on: June 15, 2024, 11:53:59 pm »
That's weird, but hey it's mobile dev, lots of stuff is weird there.

Can you open an issue about this, so we're not forgetting to have a closer look?
https://github.com/SFML/SFML/issues/new?assignees=&labels=bug&projects=&template=bug_report.yml

That it doesn't necessarily find a matching "key" for the KeyReleased event might not be as surprising, given that Android may report this as completely different keys.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

 

anything