Skip to content

Commit

Permalink
Web widgets: Prevent WebEngine to steal focus when setting html on th…
Browse files Browse the repository at this point in the history
…e page

This behavior is not present in WebKit
  • Loading branch information
ccordoba12 committed Oct 18, 2016
1 parent 1594423 commit be410cd
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion spyder/widgets/browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,22 @@ def contextMenuEvent(self, event):
add_actions(menu, actions)
menu.popup(event.globalPos())
event.accept()


def setHtml(self, html, baseUrl=QUrl()):
"""
Reimplement Qt method to prevent WebEngine to steal focus
when setting html on the page
Solution taken from
https://bugreports.qt.io/browse/QTBUG-52999
"""
if WEBENGINE:
self.setEnabled(False)
super(WebView, self).setHtml(html, baseUrl)
self.setEnabled(True)
else:
super(WebView, self).setHtml(html, baseUrl)


class WebBrowser(QWidget):
"""
Expand Down

0 comments on commit be410cd

Please sign in to comment.