diff --git a/src/Magnum/Platform/Test/GlfwApplicationTest.cpp b/src/Magnum/Platform/Test/GlfwApplicationTest.cpp index 2bcb9b030..0a1b6655e 100644 --- a/src/Magnum/Platform/Test/GlfwApplicationTest.cpp +++ b/src/Magnum/Platform/Test/GlfwApplicationTest.cpp @@ -30,6 +30,24 @@ namespace Magnum { namespace Platform { namespace Test { namespace { struct GlfwApplicationTest: Platform::Application { explicit GlfwApplicationTest(const Arguments& arguments): Platform::Application{arguments} {} + void keyPressEvent(KeyEvent& event) override { + #if GLFW_VERSION_MAJOR*100 + GLFW_VERSION_MINOR >= 302 + Debug{} << "key press event:" << event.keyName(); + #endif + + if(event.key() == KeyEvent::Key::F1) { + Debug{} << "starting text input"; + startTextInput(); + } else if(event.key() == KeyEvent::Key::Esc) { + Debug{} << "stopping text input"; + stopTextInput(); + } + } + + void textInputEvent(TextInputEvent& event) override { + Debug{} << "text input event:" << std::string{event.text(), event.text().size()}; + } + void exitEvent(ExitEvent& event) override { Debug{} << "application exiting"; event.setAccepted(); /* Comment-out to test app exit suppression */ diff --git a/src/Magnum/Platform/Test/Sdl2ApplicationTest.cpp b/src/Magnum/Platform/Test/Sdl2ApplicationTest.cpp index 414625c8b..02b6bff63 100644 --- a/src/Magnum/Platform/Test/Sdl2ApplicationTest.cpp +++ b/src/Magnum/Platform/Test/Sdl2ApplicationTest.cpp @@ -47,18 +47,29 @@ struct Sdl2ApplicationTest: Platform::Application { /* For testing event coordinates */ void mousePressEvent(MouseEvent& event) override { - Debug{} << event.position(); + Debug{} << "mouse press event:" << event.position(); } - /* For testing keyboard capture */ void keyPressEvent(KeyEvent& event) override { - Debug{} << event.keyName(); + Debug{} << "key press event:" << event.keyName(); + + if(event.key() == KeyEvent::Key::F1) { + Debug{} << "starting text input"; + startTextInput(); + } else if(event.key() == KeyEvent::Key::Esc) { + Debug{} << "stopping text input"; + stopTextInput(); + } + } + + void textInputEvent(TextInputEvent& event) override { + Debug{} << "text input event:" << std::string{event.text(), event.text().size()}; } /* Should fire on currently not handled events, such as minimize/maximize. Comment out to verify correct behavior with the override not present. */ void anyEvent(SDL_Event& event) override { - Debug{} << "any event" << event.type; + Debug{} << "any event:" << event.type; } };