From 56e58ead2299eab0ce9c81d24160de97398aa2e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Fri, 15 Mar 2024 17:16:37 +0100 Subject: [PATCH] Platform: mark events as accepted in Sdl2Application test. In the Emscripten build, accepting events in EmscriptenApplication prevents them from propagating further to the page, such as F1 that would open a browser help page. That's not the case with SDL as SDL has no concept of "accepting an event", so just document that in the test code. --- .../Platform/Test/Sdl2ApplicationTest.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/Magnum/Platform/Test/Sdl2ApplicationTest.cpp b/src/Magnum/Platform/Test/Sdl2ApplicationTest.cpp index cf38df483..882c24e5c 100644 --- a/src/Magnum/Platform/Test/Sdl2ApplicationTest.cpp +++ b/src/Magnum/Platform/Test/Sdl2ApplicationTest.cpp @@ -138,14 +138,32 @@ struct Sdl2ApplicationTest: Platform::Application { Debug{} << "requesting an exit with code 5"; exit(5); } + + /* With EmscriptenApplication, this makes the event stop from + propagating further to the page (such as when pressing F1). + Unfortunately on SDL this doesn't as there's no API to actually mark + events as accepted. */ + event.setAccepted(); } void keyReleaseEvent(KeyEvent& event) override { Debug{} << "key release event:" << SDL_Keycode(event.key()) << event.keyName(); + + /* With EmscriptenApplication, this makes the event stop from + propagating further to the page (such as when pressing F1). + Unfortunately on SDL this doesn't as there's no API to actually mark + events as accepted. */ + event.setAccepted(); } void textInputEvent(TextInputEvent& event) override { Debug{} << "text input event:" << event.text(); + + /* With EmscriptenApplication, this makes the event stop from + propagating further to the page (such as when pressing F1). + Unfortunately on SDL this doesn't as there's no API to actually mark + events as accepted. */ + event.setAccepted(); } /* Should fire on currently not handled events, such as minimize/maximize