ui: horizontal scroll fix
* prevented the mouse wheel from scrolling a horizontal scrollbar when the mouse happens to enter the scrollbar's area.
This commit is contained in:
@@ -23,6 +23,31 @@
|
|||||||
#include "settings/ApplicationSettings.h"
|
#include "settings/ApplicationSettings.h"
|
||||||
#include "settings/ColorScheme.h"
|
#include "settings/ColorScheme.h"
|
||||||
|
|
||||||
|
MouseWheelOverScrollbarFilter::MouseWheelOverScrollbarFilter(QObject* parent)
|
||||||
|
: QObject(parent)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool MouseWheelOverScrollbarFilter::eventFilter(QObject* obj, QEvent* event)
|
||||||
|
{
|
||||||
|
QScrollBar* scrollbar = dynamic_cast<QScrollBar*>(obj);
|
||||||
|
if (event->type() == QEvent::Wheel && scrollbar)
|
||||||
|
{
|
||||||
|
QRect scrollbarArea(scrollbar->pos(), scrollbar->size());
|
||||||
|
QPoint globalMousePos = dynamic_cast<QWheelEvent*>(event)->globalPos();
|
||||||
|
QPoint localMousePos = scrollbar->mapFromGlobal(globalMousePos);
|
||||||
|
|
||||||
|
// instead of "scrollbar->underMouse()" we need this check implemented here because "underMouse()"
|
||||||
|
// does not work when the mouse enters the area without being moved
|
||||||
|
if (scrollbarArea.contains(localMousePos))
|
||||||
|
{
|
||||||
|
event->ignore();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return QObject::eventFilter(obj, event);
|
||||||
|
}
|
||||||
|
|
||||||
QtCodeArea::LineNumberArea::LineNumberArea(QtCodeArea *codeArea)
|
QtCodeArea::LineNumberArea::LineNumberArea(QtCodeArea *codeArea)
|
||||||
: QWidget(codeArea)
|
: QWidget(codeArea)
|
||||||
, m_codeArea(codeArea)
|
, m_codeArea(codeArea)
|
||||||
@@ -87,6 +112,9 @@ QtCodeArea::QtCodeArea(
|
|||||||
connect(this, SIGNAL(selectionChanged()), this, SLOT(clearSelection()));
|
connect(this, SIGNAL(selectionChanged()), this, SLOT(clearSelection()));
|
||||||
|
|
||||||
this->setMouseTracking(true);
|
this->setMouseTracking(true);
|
||||||
|
|
||||||
|
// MouseWheelOverScrollbarFilter is deleted by parent.
|
||||||
|
horizontalScrollBar()->installEventFilter(new MouseWheelOverScrollbarFilter(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
QtCodeArea::~QtCodeArea()
|
QtCodeArea::~QtCodeArea()
|
||||||
|
|||||||
@@ -19,6 +19,18 @@ class QWidget;
|
|||||||
class TokenLocation;
|
class TokenLocation;
|
||||||
class TokenLocationFile;
|
class TokenLocationFile;
|
||||||
|
|
||||||
|
class MouseWheelOverScrollbarFilter
|
||||||
|
: public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
MouseWheelOverScrollbarFilter(QObject* parent);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool eventFilter(QObject*obj, QEvent* event);
|
||||||
|
};
|
||||||
|
|
||||||
class QtCodeArea
|
class QtCodeArea
|
||||||
: public QPlainTextEdit
|
: public QPlainTextEdit
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user