mirror of
https://github.com/OPM/ResInsight.git
synced 2026-08-26 21:27:15 -05:00
Use global event handler for tracking active plot window
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user