* Added new PointerEvent type. * Mouse events are still sent from Application to EntityTreeRenderer, however, EntityTreeRenderer converts them to PointerEvents * All outgoing signals from EntityTreeRenderer use PointerEvents instead of MouseEvents * Associated JavaScript entity methods will receive PointerEvents instead of MouseEvents * Events from handControllerGrab.js to entities are currently broken.
Showing the changes to libraries/script-engine/src/ScriptEngine.cpp (1 of 14 files). Show all
Unified · Split
| @@ -723,9 +723,9 @@ void ScriptEngine::addEventHandler(const EntityItemID& entityID, const QString& · 722 unmodified lines | ||
| 723 | 723 | }; |
| 724 | 724 | }; |
| 725 | 725 | |
| 726 | − using MouseHandler = std::function<void(const EntityItemID&, const MouseEvent&)>; | |
| 727 | − auto makeMouseHandler = [this](QString eventName) -> MouseHandler { | |
| 728 | − return [this, eventName](const EntityItemID& entityItemID, const MouseEvent& event) { | |
| 726 | + using PointerHandler = std::function<void(const EntityItemID&, const PointerEvent&)>; | |
| 727 | + auto makePointerHandler = [this](QString eventName) -> PointerHandler { | |
| 728 | + return [this, eventName](const EntityItemID& entityItemID, const PointerEvent& event) { | |
| 729 | 729 | forwardHandlerCall(entityItemID, eventName, { entityItemID.toScriptValue(this), event.toScriptValue(this) }); |
| 730 | 730 | }; |
| 731 | 731 | }; |
| @@ -741,17 +741,17 @@ void ScriptEngine::addEventHandler(const EntityItemID& entityID, const QString& · 9 unmodified lines | ||
| 741 | 741 | connect(entities.data(), &EntityScriptingInterface::enterEntity, this, makeSingleEntityHandler("enterEntity")); |
| 742 | 742 | connect(entities.data(), &EntityScriptingInterface::leaveEntity, this, makeSingleEntityHandler("leaveEntity")); |
| 743 | 743 | |
| 744 | − connect(entities.data(), &EntityScriptingInterface::mousePressOnEntity, this, makeMouseHandler("mousePressOnEntity")); | |
| 745 | − connect(entities.data(), &EntityScriptingInterface::mouseMoveOnEntity, this, makeMouseHandler("mouseMoveOnEntity")); | |
| 746 | − connect(entities.data(), &EntityScriptingInterface::mouseReleaseOnEntity, this, makeMouseHandler("mouseReleaseOnEntity")); | |
| 744 | + connect(entities.data(), &EntityScriptingInterface::mousePressOnEntity, this, makePointerHandler("mousePressOnEntity")); | |
| 745 | + connect(entities.data(), &EntityScriptingInterface::mouseMoveOnEntity, this, makePointerHandler("mouseMoveOnEntity")); | |
| 746 | + connect(entities.data(), &EntityScriptingInterface::mouseReleaseOnEntity, this, makePointerHandler("mouseReleaseOnEntity")); | |
| 747 | 747 | |
| 748 | − connect(entities.data(), &EntityScriptingInterface::clickDownOnEntity, this, makeMouseHandler("clickDownOnEntity")); | |
| 749 | − connect(entities.data(), &EntityScriptingInterface::holdingClickOnEntity, this, makeMouseHandler("holdingClickOnEntity")); | |
| 750 | − connect(entities.data(), &EntityScriptingInterface::clickReleaseOnEntity, this, makeMouseHandler("clickReleaseOnEntity")); | |
| 748 | + connect(entities.data(), &EntityScriptingInterface::clickDownOnEntity, this, makePointerHandler("clickDownOnEntity")); | |
| 749 | + connect(entities.data(), &EntityScriptingInterface::holdingClickOnEntity, this, makePointerHandler("holdingClickOnEntity")); | |
| 750 | + connect(entities.data(), &EntityScriptingInterface::clickReleaseOnEntity, this, makePointerHandler("clickReleaseOnEntity")); | |
| 751 | 751 | |
| 752 | − connect(entities.data(), &EntityScriptingInterface::hoverEnterEntity, this, makeMouseHandler("hoverEnterEntity")); | |
| 753 | − connect(entities.data(), &EntityScriptingInterface::hoverOverEntity, this, makeMouseHandler("hoverOverEntity")); | |
| 754 | − connect(entities.data(), &EntityScriptingInterface::hoverLeaveEntity, this, makeMouseHandler("hoverLeaveEntity")); | |
| 752 | + connect(entities.data(), &EntityScriptingInterface::hoverEnterEntity, this, makePointerHandler("hoverEnterEntity")); | |
| 753 | + connect(entities.data(), &EntityScriptingInterface::hoverOverEntity, this, makePointerHandler("hoverOverEntity")); | |
| 754 | + connect(entities.data(), &EntityScriptingInterface::hoverLeaveEntity, this, makePointerHandler("hoverLeaveEntity")); | |
| 755 | 755 | |
| 756 | 756 | connect(entities.data(), &EntityScriptingInterface::collisionWithEntity, this, makeCollisionHandler("collisionWithEntity")); |
| 757 | 757 | } |
| @@ -1546,7 +1546,7 @@ void ScriptEngine::callEntityScriptMethod(const EntityItemID& entityID, const QS · 788 unmodified lines | ||
| 1546 | 1546 | } |
| 1547 | 1547 | } |
| 1548 | 1548 | |
| 1549 | −void ScriptEngine::callEntityScriptMethod(const EntityItemID& entityID, const QString& methodName, const MouseEvent& event) { | |
| 1549 | +void ScriptEngine::callEntityScriptMethod(const EntityItemID& entityID, const QString& methodName, const PointerEvent& event) { | |
| 1550 | 1550 | if (QThread::currentThread() != thread()) { |
| 1551 | 1551 | #ifdef THREAD_DEBUGGING |
| 1552 | 1552 | qDebug() << "*** WARNING *** ScriptEngine::callEntityScriptMethod() called on wrong thread [" << QThread::currentThread() << "], invoking on correct thread [" << thread() << "] " |
| @@ -1556,12 +1556,12 @@ void ScriptEngine::callEntityScriptMethod(const EntityItemID& entityID, const QS · 3 unmodified lines | ||
| 1556 | 1556 | QMetaObject::invokeMethod(this, "callEntityScriptMethod", |
| 1557 | 1557 | Q_ARG(const EntityItemID&, entityID), |
| 1558 | 1558 | Q_ARG(const QString&, methodName), |
| 1559 | − Q_ARG(const MouseEvent&, event)); | |
| 1559 | + Q_ARG(const PointerEvent&, event)); | |
| 1560 | 1560 | return; |
| 1561 | 1561 | } |
| 1562 | 1562 | #ifdef THREAD_DEBUGGING |
| 1563 | 1563 | qDebug() << "ScriptEngine::callEntityScriptMethod() called on correct thread [" << thread() << "] " |
| 1564 | − "entityID:" << entityID << "methodName:" << methodName << "event: mouseEvent"; | |
| 1564 | + "entityID:" << entityID << "methodName:" << methodName << "event: pointerEvent"; | |
| 1565 | 1565 | #endif |
| 1566 | 1566 | |
| 1567 | 1567 | refreshFileScript(entityID); |