From 0292f06aead7305d4ab1753d6cb2c34d527bfcd2 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 19 Apr 2017 07:46:39 +0200 Subject: [PATCH] #1404 Select corresponding object before displaying context menu --- .../UserInterface/RiuPlotObjectPicker.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/ApplicationCode/UserInterface/RiuPlotObjectPicker.cpp b/ApplicationCode/UserInterface/RiuPlotObjectPicker.cpp index 4e8adb69be..46c1f6d6f3 100644 --- a/ApplicationCode/UserInterface/RiuPlotObjectPicker.cpp +++ b/ApplicationCode/UserInterface/RiuPlotObjectPicker.cpp @@ -39,13 +39,21 @@ RiuPlotObjectPicker::RiuPlotObjectPicker(QWidget* widget, caf::PdmObject* associ //-------------------------------------------------------------------------------------------------- bool RiuPlotObjectPicker::eventFilter(QObject* watchedObject, QEvent* event) { - if (event->type() == QEvent::MouseButtonRelease) + RiuMainPlotWindow* mainPlotWindow = RiaApplication::instance()->mainPlotWindow(); + if (mainPlotWindow && m_associatedObject.notNull()) { - QMouseEvent* me = static_cast(event); - if (me->button() == Qt::LeftButton) + if (event->type() == QEvent::MouseButtonPress) { - RiuMainPlotWindow* mainPlotWindow = RiaApplication::instance()->mainPlotWindow(); - if (mainPlotWindow && m_associatedObject.notNull()) + QMouseEvent* me = static_cast(event); + if (me->button() == Qt::RightButton) + { + mainPlotWindow->selectAsCurrentItem(m_associatedObject); + } + } + else if (event->type() == QEvent::MouseButtonRelease) + { + QMouseEvent* me = static_cast(event); + if (me->button() == Qt::LeftButton) { mainPlotWindow->selectAsCurrentItem(m_associatedObject); return true;