Version: 4.1 (using KDE KDE 3.1) Installed from: SuSE RPMs OS: Linux A middle mouse click onto the vertical scrollbar makes the scrollbar handle jump to the mouse position, but the document itself does not move.
I can confirm this on 3_1_BRANCH, built today. Mostly it's annoying, but it makes for some irritation in gideon in its IDEAl mode.
I know about this but am not yet sure if it is kate or Qt which is wrong... will take a look.
Subject: QScrollBar: middle mouse click doesn't emit sliderMoved() Hi, I'm working on Kate, the KDE text editor, and to save costly calculations (calculating the true number of lines) in dynamic word wrap mode we connect to the following signals of QScrollBar: connect(m_lineScroll, SIGNAL(prevPage()), SLOT(scrollPrevPage())); connect(m_lineScroll, SIGNAL(nextPage()), SLOT(scrollNextPage())); connect(m_lineScroll, SIGNAL(prevLine()), SLOT(scrollPrevLine())); connect(m_lineScroll, SIGNAL(nextLine()), SLOT(scrollNextLine())); connect(m_lineScroll, SIGNAL(sliderMoved(int)), SLOT(scrollLines(int))); Basically, everything but valueChanged(). This works almost without problems, with the exception that clicking the middle mouse button on the scrollbar does not emit sliderMoved(), only valueChanged(). The problem is that prev/next page/line also emit valueChanged() which we don't want, so we can't really connect to that. Should MMB emit sliderMoved()? I hope so, and I've attached the relevant patch... Thanks, Hamish. Created an attachment (id=905) qscrollbar.patch
Subject: Re: [Issue N16190] QScrollBar: middle mouse click doesn't emit sliderMoved() On Saturday, 08. Feb 2003 19:14 Hamish Rodda wrote: > Hi, > > I'm working on Kate, the KDE text editor, and to save costly > calculations > (calculating the true number of lines) in dynamic word wrap mode we > connect > to the following signals of QScrollBar: > > connect(m_lineScroll, SIGNAL(prevPage()), SLOT(scrollPrevPage())); > connect(m_lineScroll, SIGNAL(nextPage()), SLOT(scrollNextPage())); > > connect(m_lineScroll, SIGNAL(prevLine()), SLOT(scrollPrevLine())); > connect(m_lineScroll, SIGNAL(nextLine()), SLOT(scrollNextLine())); > > connect(m_lineScroll, SIGNAL(sliderMoved(int)), > SLOT(scrollLines(int))); > > Basically, everything but valueChanged(). > > This works almost without problems, with the exception that clicking > the > middle mouse button on the scrollbar does not emit sliderMoved(), only > valueChanged(). The problem is that prev/next page/line also emit > valueChanged() which we don't want, so we can't really connect to > that. > > Should MMB emit sliderMoved()? I hope so, and I've attached the > relevant > patch... > > Thanks, > > Hamish. > > Hi Hamish It was decided that sliderMoved should only be emitted on dragging the slider. We would break people's applications were we to change this. If you rather use valueChanged you should be able to get by. I'll see if I can update the docs somewhat to reflect this. best regards Anders Bakken -- Trolltech AS, Waldemar Thranes gate 98, NO-0175 Oslo, Norway
Subject: kdelibs/kate/part CVS commit by rodda: Fix MMB scrolling. CCMAIL:53672-done@bugs.kde.org M +32 -4 kateviewinternal.cpp 1.182 M +27 -2 kateviewinternal.h 1.74 --- kdelibs/kate/part/kateviewinternal.cpp #1.181:1.182 @@ -50,4 +50,31 @@ static const bool paintDebug = false; // const int KateViewInternal::scrollMargin = 16; +KateScrollBar::KateScrollBar(Orientation orientation, QWidget* parent, const char* name) + : QScrollBar(orientation, parent, name) + , m_middleMouseDown(false) +{ + connect(this, SIGNAL(valueChanged(int)), SLOT(sliderMaybeMoved(int))); +} + +void KateScrollBar::mousePressEvent(QMouseEvent* e) +{ + if (e->button() == MidButton) + m_middleMouseDown = true; + + QScrollBar::mousePressEvent(e); +} + +void KateScrollBar::mouseReleaseEvent(QMouseEvent* e) +{ + QScrollBar::mouseReleaseEvent(e); + + m_middleMouseDown = false; +} + +void KateScrollBar::sliderMaybeMoved(int value) +{ + if (m_middleMouseDown) + emit sliderMMBMoved(value); +} KateViewInternal::KateViewInternal(KateView *view, KateDocument *doc) @@ -77,5 +104,5 @@ KateViewInternal::KateViewInternal(KateV // scrollbar for lines // - m_lineScroll = new QScrollBar(QScrollBar::Vertical, m_view); + m_lineScroll = new KateScrollBar(QScrollBar::Vertical, m_view); m_lineScroll->show(); m_lineScroll->setTracking (true); @@ -115,4 +142,5 @@ KateViewInternal::KateViewInternal(KateV connect(m_lineScroll, SIGNAL(sliderMoved(int)), SLOT(scrollLines(int))); + connect(m_lineScroll, SIGNAL(sliderMMBMoved(int)), SLOT(scrollLines(int))); // catch wheel events, completing the hijack @@ -657,5 +685,5 @@ void KateViewInternal::paintText (int x, uint lineRangesSize = lineRanges.size(); - if ((drawBuffer.width() != width) || (drawBuffer.height() != h)) + if (((int)drawBuffer.width() != width) || ((int)drawBuffer.height() != h)) drawBuffer.resize (width, h); --- kdelibs/kate/part/kateviewinternal.h #1.73:1.74 @@ -31,6 +31,5 @@ #include <qlayout.h> #include <qpixmap.h> - -class QScrollBar; +#include <qscrollbar.h> class KateView; @@ -43,4 +42,30 @@ class KateDynWWBar; right = 1 }; + +/** + * This class is required because QScrollBar's sliderMoved() signal is + * really supposed to be a sliderDragged() signal... so this way we can capture + * MMB slider moves as well + */ +class KateScrollBar : public QScrollBar +{ + Q_OBJECT + +public: + KateScrollBar(Orientation orientation, QWidget* parent, const char* name = 0L); + +signals: + void sliderMMBMoved(int value); + +protected: + virtual void mousePressEvent(QMouseEvent* e); + virtual void mouseReleaseEvent(QMouseEvent* e); + +protected slots: + void sliderMaybeMoved(int value); + +private: + bool m_middleMouseDown; +}; class KateViewInternal : public QWidget