Skip to content

Commit

Permalink
Merge pull request #5054 from nyalldawson/canvas_select
Browse files Browse the repository at this point in the history
Ensure canvas has focus if nothing else has
  • Loading branch information
nyalldawson authored Aug 27, 2017
2 parents 37052db + a2c9710 commit d476abf
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/app/qgisapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1234,6 +1234,7 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipVersionCh
}
#endif

connect( qApp, &QApplication::focusChanged, this, &QgisApp::onFocusChanged );
} // QgisApp ctor

QgisApp::QgisApp()
Expand Down Expand Up @@ -8791,6 +8792,16 @@ void QgisApp::userRotation()
mMapCanvas->refresh();
}

void QgisApp::onFocusChanged( QWidget *oldWidget, QWidget *newWidget )
{
Q_UNUSED( oldWidget );
// If nothing has focus even though this window is active, ensure map canvas receives it
if ( !newWidget && isActiveWindow() )
{
mapCanvas()->setFocus();
}
}

// toggle overview status
void QgisApp::isInOverview()
{
Expand Down
2 changes: 2 additions & 0 deletions src/app/qgisapp.h
Original file line number Diff line number Diff line change
Expand Up @@ -1510,6 +1510,8 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow

void updateCrsStatusBar();

void onFocusChanged( QWidget *oldWidget, QWidget *newWidget );

signals:

/**
Expand Down

0 comments on commit d476abf

Please sign in to comment.