give focus on wheel scrolling
This commit is contained in:
@@ -64,6 +64,7 @@ class InnerBigText(QWidget):
|
||||
self.model = model
|
||||
self.parent = parent
|
||||
self.setFocusPolicy(Qt.FocusPolicy.StrongFocus)
|
||||
self.setFocusPolicy(Qt.FocusPolicy.WheelFocus)
|
||||
|
||||
self.font = QFont("monospace", 12)
|
||||
self.update_font_metrics(QPainter(self))
|
||||
@@ -84,13 +85,13 @@ class InnerBigText(QWidget):
|
||||
def keyPressEvent(self, e: QKeyEvent) -> None:
|
||||
lines_to_scroll = math.floor(self.lines_shown()) -1
|
||||
if e.key() == Qt.Key.Key_PageUp:
|
||||
self.scroll_by_lines(lines_to_scroll)
|
||||
if e.key() == Qt.Key.Key_PageDown:
|
||||
self.scroll_by_lines(-lines_to_scroll)
|
||||
if e.key() == Qt.Key.Key_PageDown:
|
||||
self.scroll_by_lines(lines_to_scroll)
|
||||
if e.key() == 16777235:
|
||||
self.scroll_by_lines(3)
|
||||
if e.key() == 16777237:
|
||||
self.scroll_by_lines(-3)
|
||||
if e.key() == 16777237:
|
||||
self.scroll_by_lines(3)
|
||||
|
||||
def wheelEvent(self, event: QWheelEvent):
|
||||
direction = 1 if event.angleDelta().y() < 0 else -1
|
||||
|
||||
Reference in New Issue
Block a user