From 0789d6e7e9cce4fa0cfcb60473dba24ec1974af1 Mon Sep 17 00:00:00 2001 From: Xawotihs Date: Mon, 18 Oct 2010 20:25:01 +0000 Subject: [PATCH] Activates mouse tracking --- JGE/src/Qtmain.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/JGE/src/Qtmain.cpp b/JGE/src/Qtmain.cpp index aaa728937..3b4868d59 100644 --- a/JGE/src/Qtmain.cpp +++ b/JGE/src/Qtmain.cpp @@ -44,6 +44,8 @@ protected: void mouseReleaseEvent(QMouseEvent *event); + void mouseMoveEvent(QMouseEvent *event); + void wheelEvent(QWheelEvent *event); #ifdef Q_WS_MAEMO_5 @@ -170,6 +172,7 @@ JGEQtRenderer::JGEQtRenderer(QWidget *parent) grabZoomKeys(true); #endif setAttribute(Qt::WA_AcceptTouchEvents); + setMouseTracking(true); grabGesture(Qt::PanGesture); grabGesture(Qt::PinchGesture); grabGesture(Qt::SwipeGesture); @@ -297,6 +300,14 @@ void JGEQtRenderer::mouseReleaseEvent(QMouseEvent *event) } +void JGEQtRenderer::mouseMoveEvent(QMouseEvent *event) +{ + // this is intended to convert window coordinate into game coordinate. + // this is correct only if the game and window have the same aspect ratio, otherwise, it's just wrong + g_engine->LeftClicked((event->pos().x()*SCREEN_WIDTH)/actualWidth, (event->pos().y()*SCREEN_HEIGHT)/actualHeight); + event->accept(); +} + /* void JGEQtRenderer::mousePressEvent(QMouseEvent *event) {