From 18ea028c8aed5a233f4845b2673930c20b599a2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Thu, 7 Oct 2021 17:48:22 +0200 Subject: [PATCH] python: fix InputEvent.Modifier to behave like proper flags. --- doc/python/pages/changelog.rst | 3 +++ src/python/magnum/platform/application.h | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/doc/python/pages/changelog.rst b/doc/python/pages/changelog.rst index 107fa4f..b8357c7 100644 --- a/doc/python/pages/changelog.rst +++ b/doc/python/pages/changelog.rst @@ -72,6 +72,9 @@ Changelog - Fixed a copypaste error in :ref:`platform.sdl2.Application.MouseMoveEvent.relative_position` and :ref:`platform.glfw.Application.MouseMoveEvent.relative_position` +- Fixed :ref:`platform.sdl2.Application.InputEvent.Modifier` and + :ref:`platform.glfw.Application.InputEvent.Modifier` to behave properly + as flags and not just as an enum `2020.06`_ ========== diff --git a/src/python/magnum/platform/application.h b/src/python/magnum/platform/application.h index 3c5e388..d80d11b 100644 --- a/src/python/magnum/platform/application.h +++ b/src/python/magnum/platform/application.h @@ -82,11 +82,13 @@ template void application(py::class_ void inputEvent(py::class_& c) { - py::enum_{c, "Modifier", "Modifier"} + py::enum_ modifiers{c, "Modifier", "Modifier"}; + modifiers .value("SHIFT", T::Modifier::Shift) .value("CTRL", T::Modifier::Ctrl) .value("ALT", T::Modifier::Alt) .value("SUPER", T::Modifier::Super); + corrade::enumOperators(modifiers); c.def_property("accepted", &T::isAccepted, &T::setAccepted, "Accepted status of the event"); }