SFML community forums

Help => General => Topic started by: Johannes01 on October 11, 2018, 06:23:16 pm

Title: Text Input with Thor
Post by: Johannes01 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!
Title: Re: Text Input with Thor
Post by: eXpl0it3r on October 11, 2018, 07:35:46 pm
In your callback function you pass the action context (http://www.bromeon.ch/libraries/thor/documentation/v2.1/structthor_1_1_action_context.html#a7a03fa6d9d7f5bf5103ffe44f8621cd7) which gives you access to the sf::Event and then you can do it the same way as usual.