I'm making a widgets class for some of my projects and I've implemented buttons, sliders, switches, etc, but having a problem with the input field, currently, I'm just trying to get whatever character I'm typing to print in console, but it seems like either, event.text.unicode, my computer, or my conversion method is wrong because I'm getting an output, but it's not the expected one.
here's the code. (taken directly from sfml events page,
https://www.sfml-dev.org/tutorials/2.5/window-events.php)
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
if (event.type == sf::Event::KeyPressed)
{
if (event.text.unicode < 128)
std::cout << "event.text.unicode = " << event.text.unicode << ". ASCII character returned: " <<
static_cast<char>(event.text.unicode) << std::endl;
}
}
here's the output when I click different keys:
(clicks "a" key)
event.text.unicode = 0. ASCII character returned:
(clicks "g" key)
event.text.unicode = 6. ASCII character returned:
(clicks "1" key)
event.text.unicode = 27. ASCII character returned:
(clicks "7" key)
vent.text.unicode = 33. ASCII character returned: !
(that missing "e" at the start is actually there)
(clicks "9" key)
event.text.unicode = 35. ASCII character returned: #
these are very unexpected and I don't know what to do, I looked up a Unicode char on Wikipedia
https://en.wikipedia.org/wiki/List_of_Unicode_characters but it didn't give me much info, any help would be appreciated thanks in advance.