Use global event handler for tracking active plot window

This commit is contained in:
Jon Jenssen
2026-06-17 13:55:32 +02:00
committed by JJ
parent ff4a54121f
commit 967975828c
3 changed files with 20 additions and 10 deletions
@@ -445,11 +445,7 @@ RimViewWindow* RiaGuiApplication::activePlotWindow() const
if ( m_mainPlotWindow )
{
// QList<QMdiSubWindow*> subwindows = m_mainPlotWindow->subWindowList( QMdiArea::StackingOrder );
// if ( !subwindows.empty() )
//{
// viewWindow = RiuInterfaceToViewWindow::viewWindowFromWidget( subwindows.back()->widget() );
// }
return m_mainPlotWindow->activePlotView();
}
return viewWindow;
@@ -1804,6 +1800,21 @@ bool RiaGuiApplication::notify( QObject* receiver, QEvent* event )
if ( plot ) done = plot->handleGlobalKeyEvent( keyEvent );
}
}
else if ( event->type() == QEvent::MouseButtonPress )
{
if ( activeWindow() != mainWindow() )
{
if ( auto plotMain = mainPlotWindow() )
{
QMouseEvent* mouseEvent = static_cast<QMouseEvent*>( event );
for ( auto view : plotMain->viewWindows() )
{
RimPlotWindow* plot = dynamic_cast<RimPlotWindow*>( view );
if ( plot ) done = plot->handleGlobalMousePressEvent( mouseEvent );
}
}
}
}
else if ( event->type() == QEvent::Wheel )
{
if ( activeWindow() != mainWindow() )
@@ -440,10 +440,11 @@ bool RimPlotWindow::handleGlobalWheelEvent( QWheelEvent* wheelEvent )
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPlotWindow::onMousePressEvent( QMouseEvent* mouseEvent )
bool RimPlotWindow::handleGlobalMousePressEvent( QMouseEvent* mouseEvent )
{
if ( mouseEvent )
if ( mouseEvent && viewWidget() && viewWidget()->underMouse() )
{
setAsActiveViewer();
}
return false;
}
@@ -92,9 +92,7 @@ public:
virtual bool handleGlobalKeyEvent( QKeyEvent* keyEvent );
virtual bool handleGlobalWheelEvent( QWheelEvent* wheelEvent );
public slots:
void onMousePressEvent( QMouseEvent* event );
virtual bool handleGlobalMousePressEvent( QMouseEvent* mouseEvent );
protected:
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;