New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve TextEntered events on OS X #377

Closed
mantognini opened this Issue Apr 20, 2013 · 0 comments

Comments

Projects
None yet
1 participant
@mantognini
Member

mantognini commented Apr 20, 2013

Here is a small code that show what currently happens :

#include <SFML/Window.hpp>
#include <iostream>
#include <clocale>

int main(int argc, char** argv) {
    std::setlocale(LC_ALL, "en_US.UTF-8");

    sf::Window wnd(sf::VideoMode(100, 100), "test window");

    while (wnd.isOpen()) {
        sf::Event event;
        while (wnd.pollEvent(event)) {
            if (event.type == sf::Event::KeyPressed)
                std::wcout << "[KeyPressed]  key code: " << event.key.code << std::endl;
            else if (event.type == sf::Event::KeyReleased)
                std::wcout << "[KeyReleased]  key code: " << event.key.code << std::endl;
            else if (event.type == sf::Event::TextEntered)
                std::wcout << "[TextEntered]  unicode: " << event.text.unicode <<
                              "\tcharacter: " << static_cast<wchar_t>(event.text.unicode) << std::endl;
            else if (event.type == sf::Event::Closed)
                wnd.close();
        }

        wnd.display();
    }
}

Here are two outputs (from two different keyboard layouts) and their corresponding expected output.

A

current output

[KeyPressed]  key code: 43
[KeyPressed]  key code: 55
[KeyReleased]  key code: 55
[KeyReleased]  key code: 43
[KeyPressed]  key code: 4
[TextEntered]  unicode: 101 character: e
[KeyReleased]  key code: 4

expected output

[KeyPressed]  key code: 43
[KeyPressed]  key code: 55
[KeyReleased]  key code: 55
[KeyReleased]  key code: 43
[KeyPressed]  key code: 4
[TextEntered]  unicode: 233 character: é
[KeyReleased]  key code: 4

B

current output

[KeyPressed]  key code: 55
[KeyReleased]  key code: 55
[KeyPressed]  key code: 4
[TextEntered]  unicode: 101   character: 'e'
[KeyReleased]  key code: 4

expected output

[KeyPressed]  key code: 55
[KeyReleased]  key code: 55
[KeyPressed]  key code: 4
[TextEntered]  unicode: 233   character: 'é'
[KeyReleased]  key code: 4

(43 is the right alt, 55 is ´ and 4 is e)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment