Hello,
Ive been searching lately for a solution, i havnt found yet, for a problem using Textentered event and android virtual keyboard.
The std::string doesnt seem to recieve over 128 unicode characters, specially arabic letters and the erase to the lift button (U+232B).
I tried using wstring and fonts that support these characters, i even tried using sf::String and convert it to wide string, but the problem persist.
Here is my code, last edited, showing only whats related to my issue:
// after enabling the virtual keyboard
wstring str0;
sf::Text txt0;
if (event.type == sf::Event::TextEntered)
{
if (str0.size()<=15) str0+=event.text.unicode;
if (event.text.unicode==L'\n')
{
str0.erase(str0.size()-1, 1);
}
if (event.text.unicode==L'\u232B')
{
str0.erase(str0.size()-2, 2);
}
txt0.setString(str0);
}
this code works with English letters and the enter button in the virtual keyboard, but it doesnt work with arabic nor the erase to the left character.
Note: im testing this only on Android, using a HUAWEI device with Android 8 OS.
my laptop support arabic alphabet. i tried to generate your error but no avail every things looks work fine from SFML side.
just to clarify things:
does this "erase to left character" means "BackSpace" on the keyboard?
i made minimal example by using `'\b'` and `'\r'` which is working fine as i said before. other wise you have to write your own minimal example which's cause the issue to let the others to test your code and solve the problem.
#include <SFML/Window.hpp>
int main()
{
sf::Window window({ 640 ,480 }, "test arabic alphabet");
std::wstring arabic_str;
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
else if (event.type == sf::Event::TextEntered)
{
if (event.text.unicode == '\b') // press backspace
{
if (!arabic_str.empty())
arabic_str.pop_back();
}
else if (event.text.unicode == '\r') // press enter/return
{
if (!arabic_str.empty())
arabic_str.pop_back();
}
else {
arabic_str += event.text.unicode;
}
}
}
window.setTitle(arabic_str);
window.display();
}
}