Showing the changes to libraries/script-engine/src/EventTypes.cpp (1 of 5 files). Show all
Unified · Split
| @@ -13,87 +13,18 @@ · 12 unmodified lines | ||
| 13 | 13 | #include <RegisteredMetaTypes.h> |
| 14 | 14 | |
| 15 | 15 | #include "KeyEvent.h" |
| 16 | +#include "MouseEvent.h" | |
| 16 | 17 | |
| 17 | 18 | #include "EventTypes.h" |
| 18 | 19 | |
| 19 | − | |
| 20 | 20 | void registerEventTypes(QScriptEngine* engine) { |
| 21 | 21 | qScriptRegisterMetaType(engine, KeyEvent::toScriptValue, KeyEvent::fromScriptValue); |
| 22 | − qScriptRegisterMetaType(engine, mouseEventToScriptValue, mouseEventFromScriptValue); | |
| 22 | + qScriptRegisterMetaType(engine, MouseEvent::toScriptValue, MouseEvent::fromScriptValue); | |
| 23 | 23 | qScriptRegisterMetaType(engine, touchEventToScriptValue, touchEventFromScriptValue); |
| 24 | 24 | qScriptRegisterMetaType(engine, wheelEventToScriptValue, wheelEventFromScriptValue); |
| 25 | 25 | qScriptRegisterMetaType(engine, spatialEventToScriptValue, spatialEventFromScriptValue); |
| 26 | 26 | } |
| 27 | 27 | |
| 28 | − | |
| 29 | − | |
| 30 | −MouseEvent::MouseEvent() : | |
| 31 | − x(0.0f), | |
| 32 | − y(0.0f), | |
| 33 | − isLeftButton(false), | |
| 34 | − isRightButton(false), | |
| 35 | − isMiddleButton(false), | |
| 36 | − isShifted(false), | |
| 37 | − isControl(false), | |
| 38 | − isMeta(false), | |
| 39 | − isAlt(false) | |
| 40 | −{ | |
| 41 | −}; | |
| 42 | − | |
| 43 | − | |
| 44 | −MouseEvent::MouseEvent(const QMouseEvent& event, const unsigned int deviceID) : | |
| 45 | − x(event.x()), | |
| 46 | − y(event.y()), | |
| 47 | − deviceID(deviceID), | |
| 48 | − isLeftButton(event.buttons().testFlag(Qt::LeftButton)), | |
| 49 | − isRightButton(event.buttons().testFlag(Qt::RightButton)), | |
| 50 | − isMiddleButton(event.buttons().testFlag(Qt::MiddleButton)), | |
| 51 | − isShifted(event.modifiers().testFlag(Qt::ShiftModifier)), | |
| 52 | − isControl(event.modifiers().testFlag(Qt::ControlModifier)), | |
| 53 | − isMeta(event.modifiers().testFlag(Qt::MetaModifier)), | |
| 54 | − isAlt(event.modifiers().testFlag(Qt::AltModifier)) | |
| 55 | −{ | |
| 56 | − // single button that caused the event | |
| 57 | − switch (event.button()) { | |
| 58 | − case Qt::LeftButton: | |
| 59 | − button = "LEFT"; | |
| 60 | − isLeftButton = true; | |
| 61 | − break; | |
| 62 | − case Qt::RightButton: | |
| 63 | − button = "RIGHT"; | |
| 64 | − isRightButton = true; | |
| 65 | − break; | |
| 66 | − case Qt::MiddleButton: | |
| 67 | − button = "MIDDLE"; | |
| 68 | − isMiddleButton = true; | |
| 69 | − break; | |
| 70 | − default: | |
| 71 | − button = "NONE"; | |
| 72 | − break; | |
| 73 | − } | |
| 74 | −} | |
| 75 | − | |
| 76 | −QScriptValue mouseEventToScriptValue(QScriptEngine* engine, const MouseEvent& event) { | |
| 77 | − QScriptValue obj = engine->newObject(); | |
| 78 | − obj.setProperty("x", event.x); | |
| 79 | − obj.setProperty("y", event.y); | |
| 80 | − obj.setProperty("button", event.button); | |
| 81 | − obj.setProperty("deviceID", event.deviceID); | |
| 82 | − obj.setProperty("isLeftButton", event.isLeftButton); | |
| 83 | − obj.setProperty("isRightButton", event.isRightButton); | |
| 84 | − obj.setProperty("isMiddleButton", event.isMiddleButton); | |
| 85 | − obj.setProperty("isShifted", event.isShifted); | |
| 86 | − obj.setProperty("isMeta", event.isMeta); | |
| 87 | − obj.setProperty("isControl", event.isControl); | |
| 88 | − obj.setProperty("isAlt", event.isAlt); | |
| 89 | − | |
| 90 | − return obj; | |
| 91 | −} | |
| 92 | − | |
| 93 | −void mouseEventFromScriptValue(const QScriptValue& object, MouseEvent& event) { | |
| 94 | − // nothing for now... | |
| 95 | −} | |
| 96 | − | |
| 97 | 28 | TouchEvent::TouchEvent() : |
| 98 | 29 | x(0.0f), |
| 99 | 30 | y(0.0f), |