History

Merge pull request #6022 from jherico/lisa

Fix mouse events for entity scripts

Brad Hefta-Gaub committed 11 years ago

Commit e1b69a12 parents 7c286a4 50592a81 file · +30 −32Browse files

Showing the changes to interface/src/Application.cpp (1 of 1 file). Show all

Unified · Split

interface/src/Application.cpp+30−32
@@ -1825,17 +1825,16 @@ void Application::mouseMoveEvent(QMouseEvent* event, unsigned int deviceID) { · 1824 unmodified lines
1825 }1825 }
1826#endif1826#endif
1827 1827
1828 auto offscreenUi = DependencyManager::get<OffscreenUi>();
1829 QPointF transformedPos = offscreenUi->mapToVirtualScreen(event->localPos(), _glWidget);
1830 QMouseEvent mappedEvent(event->type(),
1831 transformedPos,
1832 event->screenPos(), event->button(),
1833 event->buttons(), event->modifiers());
1828 1834
1829 _entities.mouseMoveEvent(event, deviceID);1835
1830 {1836 _entities.mouseMoveEvent(&mappedEvent, deviceID);
1831 auto offscreenUi = DependencyManager::get<OffscreenUi>();1837 _controllerScriptingInterface.emitMouseMoveEvent(&mappedEvent, deviceID); // send events to any registered scripts
1832 QPointF transformedPos = offscreenUi->mapToVirtualScreen(event->localPos(), _glWidget);
1833 QMouseEvent mappedEvent(event->type(),
1834 transformedPos,
1835 event->screenPos(), event->button(),
1836 event->buttons(), event->modifiers());
1837 _controllerScriptingInterface.emitMouseMoveEvent(&mappedEvent, deviceID); // send events to any registered scripts
1838 }
1839 1838
1840 // if one of our scripts have asked to capture this event, then stop processing it1839 // if one of our scripts have asked to capture this event, then stop processing it
1841 if (_controllerScriptingInterface.isMouseCaptured()) {1840 if (_controllerScriptingInterface.isMouseCaptured()) {
@@ -1851,19 +1850,19 @@ void Application::mouseMoveEvent(QMouseEvent* event, unsigned int deviceID) { · 9 unmodified lines
1851void Application::mousePressEvent(QMouseEvent* event, unsigned int deviceID) {1850void Application::mousePressEvent(QMouseEvent* event, unsigned int deviceID) {
1852 // Inhibit the menu if the user is using alt-mouse dragging1851 // Inhibit the menu if the user is using alt-mouse dragging
1853 _altPressed = false;1852 _altPressed = false;
1853
1854 auto offscreenUi = DependencyManager::get<OffscreenUi>();
1855 QPointF transformedPos = offscreenUi->mapToVirtualScreen(event->localPos(), _glWidget);
1856 QMouseEvent mappedEvent(event->type(),
1857 transformedPos,
1858 event->screenPos(), event->button(),
1859 event->buttons(), event->modifiers());
1860
1854 if (!_aboutToQuit) {1861 if (!_aboutToQuit) {
1855 _entities.mousePressEvent(event, deviceID);1862 _entities.mousePressEvent(&mappedEvent, deviceID);
1856 }1863 }
1857 1864
1858 {1865 _controllerScriptingInterface.emitMousePressEvent(&mappedEvent); // send events to any registered scripts
1859 auto offscreenUi = DependencyManager::get<OffscreenUi>();
1860 QPointF transformedPos = offscreenUi->mapToVirtualScreen(event->localPos(), _glWidget);
1861 QMouseEvent mappedEvent(event->type(),
1862 transformedPos,
1863 event->screenPos(), event->button(),
1864 event->buttons(), event->modifiers());
1865 _controllerScriptingInterface.emitMousePressEvent(&mappedEvent); // send events to any registered scripts
1866 }
1867 1866
1868 // if one of our scripts have asked to capture this event, then stop processing it1867 // if one of our scripts have asked to capture this event, then stop processing it
1869 if (_controllerScriptingInterface.isMouseCaptured()) {1868 if (_controllerScriptingInterface.isMouseCaptured()) {
@@ -1879,7 +1878,7 @@ void Application::mousePressEvent(QMouseEvent* event, unsigned int deviceID) { · 9 unmodified lines
1879 if (event->button() == Qt::LeftButton) {1878 if (event->button() == Qt::LeftButton) {
1880 // nobody handled this - make it an action event on the _window object1879 // nobody handled this - make it an action event on the _window object
1881 HFActionEvent actionEvent(HFActionEvent::startType(),1880 HFActionEvent actionEvent(HFActionEvent::startType(),
1882 computePickRay(event->x(), event->y()));1881 computePickRay(mappedEvent.x(), mappedEvent.y()));
1883 sendEvent(this, &actionEvent);1882 sendEvent(this, &actionEvent);
1884 1883
1885 } else if (event->button() == Qt::RightButton) {1884 } else if (event->button() == Qt::RightButton) {
@@ -1907,19 +1906,18 @@ void Application::mouseDoublePressEvent(QMouseEvent* event, unsigned int deviceI · 21 unmodified lines
1907 1906
1908void Application::mouseReleaseEvent(QMouseEvent* event, unsigned int deviceID) {1907void Application::mouseReleaseEvent(QMouseEvent* event, unsigned int deviceID) {
1909 1908
1909 auto offscreenUi = DependencyManager::get<OffscreenUi>();
1910 QPointF transformedPos = offscreenUi->mapToVirtualScreen(event->localPos(), _glWidget);
1911 QMouseEvent mappedEvent(event->type(),
1912 transformedPos,
1913 event->screenPos(), event->button(),
1914 event->buttons(), event->modifiers());
1915
1910 if (!_aboutToQuit) {1916 if (!_aboutToQuit) {
1911 _entities.mouseReleaseEvent(event, deviceID);1917 _entities.mouseReleaseEvent(&mappedEvent, deviceID);
1912 }1918 }
1913 1919
1914 {1920 _controllerScriptingInterface.emitMouseReleaseEvent(&mappedEvent); // send events to any registered scripts
1915 auto offscreenUi = DependencyManager::get<OffscreenUi>();
1916 QPointF transformedPos = offscreenUi->mapToVirtualScreen(event->localPos(), _glWidget);
1917 QMouseEvent mappedEvent(event->type(),
1918 transformedPos,
1919 event->screenPos(), event->button(),
1920 event->buttons(), event->modifiers());
1921 _controllerScriptingInterface.emitMouseReleaseEvent(&mappedEvent); // send events to any registered scripts
1922 }
1923 1921
1924 // if one of our scripts have asked to capture this event, then stop processing it1922 // if one of our scripts have asked to capture this event, then stop processing it
1925 if (_controllerScriptingInterface.isMouseCaptured()) {1923 if (_controllerScriptingInterface.isMouseCaptured()) {
@@ -1934,7 +1932,7 @@ void Application::mouseReleaseEvent(QMouseEvent* event, unsigned int deviceID) { · 8 unmodified lines
1934 if (event->button() == Qt::LeftButton) {1932 if (event->button() == Qt::LeftButton) {
1935 // fire an action end event1933 // fire an action end event
1936 HFActionEvent actionEvent(HFActionEvent::endType(),1934 HFActionEvent actionEvent(HFActionEvent::endType(),
1937 computePickRay(event->x(), event->y()));1935 computePickRay(mappedEvent.x(), mappedEvent.y()));
1938 sendEvent(this, &actionEvent);1936 sendEvent(this, &actionEvent);
1939 }1937 }
1940 }1938 }