Keep keyboard focus if scene item other than proxy widget is clicked

This commit is contained in:
G.K.MacGregor
2022-05-15 13:08:58 +01:00
parent ec4bdd6f7f
commit bcc0d0d8e7
2 changed files with 25 additions and 1 deletions

View File

@@ -703,6 +703,7 @@ void LevelOneScene::hideGUIElements(bool hidden)
}
}
// Implements Ctrl+mousewheel zoom
bool LevelOneScene::eventFilter(QObject *object, QEvent *event)
{
Q_UNUSED(object);
@@ -719,6 +720,26 @@ bool LevelOneScene::eventFilter(QObject *object, QEvent *event)
return false;
}
// Clicking outside the main text widget but still within the scene would
// cause keyboard focus loss.
// So on every keypress within the scene, wrench the focus back to the widget
// if necessary.
void LevelOneScene::keyPressEvent(QKeyEvent *keyEvent)
{
if (focusItem() != m_levelOneProxyWidget)
setFocusItem(m_levelOneProxyWidget);
QGraphicsScene::keyPressEvent(keyEvent);
}
void LevelOneScene::keyReleaseEvent(QKeyEvent *keyEvent)
{
if (focusItem() != m_levelOneProxyWidget)
setFocusItem(m_levelOneProxyWidget);
QGraphicsScene::keyReleaseEvent(keyEvent);
}
void LevelOneScene::setFullScreenColour(const QColor &newColor)
{
if (!static_cast<TeletextWidget *>(m_levelOneProxyWidget->widget())->pageRender()->mix()) {