Adjust QtWebKit _key_press to QtWebEngine one

This commit is contained in:
Florian Bruhin 2016-07-07 11:09:51 +02:00
parent 47ce6aff89
commit b78de501c2

View File

@ -25,6 +25,7 @@ import xml.etree.ElementTree
from PyQt5.QtCore import pyqtSlot, Qt, QEvent, QUrl, QPoint, QTimer
from PyQt5.QtGui import QKeyEvent
from PyQt5.QtWidgets import QApplication
from PyQt5.QtWebKitWidgets import QWebPage
from PyQt5.QtWebKit import QWebSettings
@ -352,16 +353,13 @@ class WebViewScroller(tabmod.AbstractScroller):
release_evt = QKeyEvent(QEvent.KeyRelease, key, Qt.NoModifier, 0, 0, 0)
getter = None if getter_name is None else getattr(frame, getter_name)
# FIXME needed?
# self._widget.setFocus()
for _ in range(count):
# Abort scrolling if the minimum/maximum was reached.
if (getter is not None and
frame.scrollBarValue(direction) == getter(direction)):
return
self._widget.keyPressEvent(press_evt)
self._widget.keyReleaseEvent(release_evt)
QApplication.postEvent(self._widget, press_evt)
QApplication.postEvent(self._widget, release_evt)
def up(self, count=1):
self._key_press(Qt.Key_Up, count, 'scrollBarMinimum', Qt.Vertical)