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

Author Topic: Text Input with Thor  (Read 1197 times)

0 Members and 1 Guest are viewing this topic.

Johannes01

  • Newbie
  • *
  • Posts: 3
    • View Profile
Text Input with Thor
« on: October 11, 2018, 06:23:16 pm »
I recently started using Thor and I encountered this problem. Before using Thor I would create text input fields like this:

sf::Event event;

    while (this->window->getWindow()->pollEvent(event))
    {
        if (event.type == sf::Event::TextEntered)
        {
            if (event.text.unicode < 128) {
                if (event.text.unicode == 8) { // backspace
                    if (raw.length() > 0) raw = raw.substr(0, raw.size() - 1);
                }
                else if (event.text.unicode == 13) { // enter
                    entered = true;
                }
                else {
                    raw += (char)event.text.unicode;
                }
            }
        }
    }

With the action maping system of Thor however I have no idea how to get to the event.text.unicode
Thanks in advance!
« Last Edit: October 11, 2018, 06:27:32 pm by Johannes01 »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: Text Input with Thor
« Reply #1 on: October 11, 2018, 07:35:46 pm »
In your callback function you pass the action context which gives you access to the sf::Event and then you can do it the same way as usual.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/