mirror of
https://github.com/huderlem/porymap.git
synced 2026-08-28 11:36:26 -05:00
Stop QTextEdit from stealing scroll focus
This commit is contained in:
25
include/ui/noscrolltextedit.h
Normal file
25
include/ui/noscrolltextedit.h
Normal file
@@ -0,0 +1,25 @@
|
||||
#ifndef NOSCROLLTEXTEDIT_H
|
||||
#define NOSCROLLTEXTEDIT_H
|
||||
|
||||
#include <QTextEdit>
|
||||
#include <QWheelEvent>
|
||||
|
||||
class NoScrollTextEdit : public QTextEdit
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit NoScrollTextEdit(const QString &text, QWidget *parent = nullptr) : QTextEdit(text, parent) {
|
||||
setFocusPolicy(Qt::StrongFocus);
|
||||
};
|
||||
explicit NoScrollTextEdit(QWidget *parent = nullptr) : NoScrollTextEdit(QString(), parent) {};
|
||||
|
||||
virtual void wheelEvent(QWheelEvent *event) override {
|
||||
if (hasFocus()) {
|
||||
QTextEdit::wheelEvent(event);
|
||||
} else {
|
||||
event->ignore();
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
#endif // NOSCROLLTEXTEDIT_H
|
||||
Reference in New Issue
Block a user