From 674a0e78f69fb49c5512ddf03fe32597dc7ca209 Mon Sep 17 00:00:00 2001 From: David Rosca Date: Tue, 13 Mar 2018 18:44:28 +0100 Subject: [PATCH] WebView: Workaround QtWebEngine issue where webview loses focus --- src/lib/webengine/webview.cpp | 11 +++++++++++ src/lib/webengine/webview.h | 2 ++ 2 files changed, 13 insertions(+) diff --git a/src/lib/webengine/webview.cpp b/src/lib/webengine/webview.cpp index 66d43bf53..fb6d044c1 100644 --- a/src/lib/webengine/webview.cpp +++ b/src/lib/webengine/webview.cpp @@ -1268,6 +1268,17 @@ void WebView::contextMenuEvent(QContextMenuEvent *event) }); } +bool WebView::focusNextPrevChild(bool next) +{ + // QTBUG-67043 + // Workaround QtWebEngine issue where QWebEngineView loses focus on second load() call. + if (next) { + setFocus(); + return false; + } + return QWebEngineView::focusNextPrevChild(next); +} + void WebView::loadRequest(const LoadRequest &req) { QWebEngineView::load(req.webRequest()); diff --git a/src/lib/webengine/webview.h b/src/lib/webengine/webview.h index 6e7e76bb8..9893e798b 100644 --- a/src/lib/webengine/webview.h +++ b/src/lib/webengine/webview.h @@ -145,6 +145,8 @@ protected: void resizeEvent(QResizeEvent *event) override; void contextMenuEvent(QContextMenuEvent *event) override; + bool focusNextPrevChild(bool next) override; + virtual void _wheelEvent(QWheelEvent *event); virtual void _mousePressEvent(QMouseEvent *event); virtual void _mouseReleaseEvent(QMouseEvent *event);