diff options
Diffstat (limited to 'src/events/KeyPressedEvent.hpp')
| -rw-r--r-- | src/events/KeyPressedEvent.hpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/events/KeyPressedEvent.hpp b/src/events/KeyPressedEvent.hpp new file mode 100644 index 0000000..8c7ded1 --- /dev/null +++ b/src/events/KeyPressedEvent.hpp @@ -0,0 +1,25 @@ +#pragma once + +#include <QtCore> +#include <lua.hpp> +#include <qevent.h> + +#include "events/Event.hpp" + +class KeyPressedEvent : public Event { +public: + const QString key; + + KeyPressedEvent(QString key) : key(std::move(key)) { kind = "KeyPressed"; } + + static KeyPressedEvent *from_qkeyevent(QKeyEvent *qevent) { + // TODO: Using with modifiers + auto *event = new KeyPressedEvent(qevent->text()); + return event; + } + + void lua_push(lua_State *state) const override { + Event::lua_push(state); + SET_FIELD("key", string, key.toStdString().c_str()) + } +}; |
