Showing the changes to libraries/script-engine/src/ScriptEngine.cpp (1 of 1 file). Show all
Unified · Split
| @@ -509,18 +509,22 @@ void ScriptEngine::addEventHandler(const EntityItemID& entityID, const QString& · 508 unmodified lines | |||
| 509 | }); | 509 | }); |
| 510 | 510 | ||
| 511 | // Two common cases of event handler, differing only in argument signature. | 511 | // Two common cases of event handler, differing only in argument signature. |
| 512 | auto makeSingleEntityHandler = [&](QString eventName) { | 512 | using SingleEntityHandler = std::function<void(const EntityItemID&)>; |
| 513 | auto makeSingleEntityHandler = [this](QString eventName) -> SingleEntityHandler { | ||
| 513 | return [this, eventName](const EntityItemID& entityItemID) { | 514 | return [this, eventName](const EntityItemID& entityItemID) { |
| 514 | forwardHandlerCall(entityItemID, eventName, { entityItemID.toScriptValue(this) }); | 515 | forwardHandlerCall(entityItemID, eventName, { entityItemID.toScriptValue(this) }); |
| 515 | }; | 516 | }; |
| 516 | }; | 517 | }; |
| 517 | auto makeMouseHandler = [&](QString eventName) { | 518 | |
| 519 | using MouseHandler = std::function<void(const EntityItemID&, const MouseEvent&)>; | ||
| 520 | auto makeMouseHandler = [this](QString eventName) -> MouseHandler { | ||
| 518 | return [this, eventName](const EntityItemID& entityItemID, const MouseEvent& event) { | 521 | return [this, eventName](const EntityItemID& entityItemID, const MouseEvent& event) { |
| 519 | forwardHandlerCall(entityItemID, eventName, { entityItemID.toScriptValue(this), event.toScriptValue(this) }); | 522 | forwardHandlerCall(entityItemID, eventName, { entityItemID.toScriptValue(this), event.toScriptValue(this) }); |
| 520 | }; | 523 | }; |
| 521 | }; | 524 | }; |
| 522 | 525 | ||
| 523 | auto makeCollisionHandler = [&](QString eventName) { | 526 | using CollisionHandler = std::function<void(const EntityItemID&, const EntityItemID&, const Collision&)>; |
| 527 | auto makeCollisionHandler = [this](QString eventName) -> CollisionHandler { | ||
| 524 | return [this, eventName](const EntityItemID& idA, const EntityItemID& idB, const Collision& collision) { | 528 | return [this, eventName](const EntityItemID& idA, const EntityItemID& idB, const Collision& collision) { |
| 525 | forwardHandlerCall(idA, eventName, { idA.toScriptValue(this), idB.toScriptValue(this), | 529 | forwardHandlerCall(idA, eventName, { idA.toScriptValue(this), idB.toScriptValue(this), |
| 526 | collisionToScriptValue(this, collision) }); | 530 | collisionToScriptValue(this, collision) }); |