Showing the changes to libraries/script-engine/src/EventTypes.cpp (1 of 16 files). Show all
Unified · Split
| @@ -17,15 +17,18 @@ · 16 unmodified lines | ||
| 17 | 17 | #include "PointerEvent.h" |
| 18 | 18 | #include "ScriptEngine.h" |
| 19 | 19 | #include "ScriptEngineCast.h" |
| 20 | +#include "ScriptManager.h" | |
| 20 | 21 | #include "SpatialEvent.h" |
| 21 | 22 | #include "TouchEvent.h" |
| 22 | 23 | #include "WheelEvent.h" |
| 23 | 24 | |
| 24 | −void registerEventTypes(ScriptEngine* engine) { | |
| 25 | − scriptRegisterMetaType<KeyEvent, KeyEvent::toScriptValue, KeyEvent::fromScriptValue>(engine, "KeyEvent"); | |
| 26 | − scriptRegisterMetaType<MouseEvent, MouseEvent::toScriptValue, MouseEvent::fromScriptValue>(engine, "MouseEvent"); | |
| 27 | − scriptRegisterMetaType<PointerEvent, PointerEvent::toScriptValue, PointerEvent::fromScriptValue>(engine, "PointerEvent"); | |
| 28 | − scriptRegisterMetaType<TouchEvent, TouchEvent::toScriptValue, TouchEvent::fromScriptValue>(engine, "TouchEvent"); | |
| 29 | − scriptRegisterMetaType<WheelEvent, WheelEvent::toScriptValue, WheelEvent::fromScriptValue>(engine, "WheelEvent"); | |
| 30 | − scriptRegisterMetaType<SpatialEvent, SpatialEvent::toScriptValue, SpatialEvent::fromScriptValue>(engine, "SpatialEvent"); | |
| 31 | −} | |
| 25 | +STATIC_SCRIPT_TYPES_INITIALIZER((+[](ScriptManager* manager){ | |
| 26 | + auto scriptEngine = manager->engine().get(); | |
| 27 | + | |
| 28 | + scriptRegisterMetaType<KeyEvent, KeyEvent::toScriptValue, KeyEvent::fromScriptValue>(scriptEngine, "KeyEvent"); | |
| 29 | + scriptRegisterMetaType<MouseEvent, MouseEvent::toScriptValue, MouseEvent::fromScriptValue>(scriptEngine, "MouseEvent"); | |
| 30 | + scriptRegisterMetaType<PointerEvent, PointerEvent::toScriptValue, PointerEvent::fromScriptValue>(scriptEngine, "PointerEvent"); | |
| 31 | + scriptRegisterMetaType<TouchEvent, TouchEvent::toScriptValue, TouchEvent::fromScriptValue>(scriptEngine, "TouchEvent"); | |
| 32 | + scriptRegisterMetaType<WheelEvent, WheelEvent::toScriptValue, WheelEvent::fromScriptValue>(scriptEngine, "WheelEvent"); | |
| 33 | + scriptRegisterMetaType<SpatialEvent, SpatialEvent::toScriptValue, SpatialEvent::fromScriptValue>(scriptEngine, "SpatialEvent"); | |
| 34 | +})); | |