aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Fadel <samuelfadel@gmail.com>2016-02-08 20:38:37 -0200
committerSamuel Fadel <samuelfadel@gmail.com>2016-02-08 20:38:37 -0200
commitd79e037df56236c7d0f0824853b292d15ab75c27 (patch)
treed1a5764bf5251482adf96103c8fb88ede4acc8b2
parent6ce50a77d7659e5e7fbcaceead0e17d37ce8856d (diff)
Scatterplot: interaction now happens only via left mouse button.
-rw-r--r--main.h4
-rw-r--r--scatterplot.cpp18
2 files changed, 20 insertions, 2 deletions
diff --git a/main.h b/main.h
index d3184da..550b0e4 100644
--- a/main.h
+++ b/main.h
@@ -62,7 +62,7 @@ public:
cpPlot->setAcceptedMouseButtons(Qt::NoButton);
cpPlot->setAcceptHoverEvents(false);
- rpPlot->setAcceptedMouseButtons(Qt::LeftButton | Qt::MiddleButton | Qt::RightButton);
+ rpPlot->setAcceptedMouseButtons(Qt::LeftButton);
rpPlot->setAcceptHoverEvents(true);
}
@@ -70,7 +70,7 @@ public:
rpPlot->setAcceptedMouseButtons(Qt::NoButton);
rpPlot->setAcceptHoverEvents(false);
- cpPlot->setAcceptedMouseButtons(Qt::LeftButton | Qt::MiddleButton | Qt::RightButton);
+ cpPlot->setAcceptedMouseButtons(Qt::LeftButton);
cpPlot->setAcceptHoverEvents(true);
}
diff --git a/scatterplot.cpp b/scatterplot.cpp
index f501267..ca65c2c 100644
--- a/scatterplot.cpp
+++ b/scatterplot.cpp
@@ -31,6 +31,9 @@ static const QColor CROSSHAIR_COLOR2(0, 0, 0);
// Selection settings
static const QColor SELECTION_COLOR(128, 128, 128, 96);
+// The mouse button used for interaction
+static const Qt::MouseButton MOUSE_BUTTON = Qt::LeftButton;
+
class QuadTree
{
public:
@@ -582,6 +585,10 @@ void Scatterplot::updateBrush(QSGNode *node)
void Scatterplot::mousePressEvent(QMouseEvent *event)
{
+ if (!(event->buttons() & MOUSE_BUTTON)) {
+ return;
+ }
+
switch (m_interactionState) {
case STATE_NONE:
case STATE_SELECTED:
@@ -602,6 +609,10 @@ void Scatterplot::mousePressEvent(QMouseEvent *event)
void Scatterplot::mouseMoveEvent(QMouseEvent *event)
{
+ if (!(event->buttons() & MOUSE_BUTTON)) {
+ return;
+ }
+
switch (m_interactionState) {
case STATE_SELECTING:
m_dragCurrentPos = event->localPos();
@@ -623,6 +634,13 @@ void Scatterplot::mouseMoveEvent(QMouseEvent *event)
void Scatterplot::mouseReleaseEvent(QMouseEvent *event)
{
+ if (event->buttons() & MOUSE_BUTTON) {
+ // From the docs: for mouse release events, buttons() excludes the
+ // button that caused the event. Therefore, we bail out if the button is
+ // included in buttons().
+ return;
+ }
+
switch (m_interactionState) {
case STATE_NONE:
case STATE_SELECTED: