Abdelrazak Younes wrote:
Hello,

I had an idea: if clicking in the scrollbar should behave like PageDown or PageUp, why not using the same LFUNs as the one used by the keyboard action?

This patch is doing just that ;-). It is so simple that I wonder why it has not been done before. Of course it works fine only when cursor_follows_scrollbar is set. I've tried to restore the cursor when it is not the case (in WorkAre::scrollBarAction()) but it doesn't work reliably. So I have two questions:

1) Does anyone see any shortcoming to this solution when cursor_follows_scrollbar is set? If not, I'd like to put it in.

2) Anyone knows how to restore the cursor reliably?

Actually it is restored fine. I was misleaded by the fact that cursorDown does not go back to the cursor but starts at the beginning of the screen. But this bug is also present without my patch!

So, here is the updated patch. Please test it. I think the current scrollbar behaviour presents big usability problems.

Abdel.
Index: frontends/qt4/GuiWorkArea.C
===================================================================
--- frontends/qt4/GuiWorkArea.C (revision 16545)
+++ frontends/qt4/GuiWorkArea.C (working copy)
@@ -36,6 +36,7 @@
 #include "graphics/GraphicsImage.h"
 #include "graphics/GraphicsLoader.h"
 
+#include <QAbstractSlider>
 #include <QLayout>
 #include <QMainWindow>
 #include <QMimeData>
@@ -225,9 +226,23 @@
 }
 
 
-void GuiWorkArea::adjustViewWithScrollBar(int)
+void GuiWorkArea::adjustViewWithScrollBar(int action)
 {
-       scrollBufferView(verticalScrollBar()->sliderPosition());
+       switch (action) {
+               case QAbstractSlider::SliderPageStepAdd:
+                       scrollBarAction(LFUN_SCREEN_DOWN);
+                       break;
+               case QAbstractSlider::SliderPageStepSub:
+                       scrollBarAction(LFUN_SCREEN_UP);
+                       break;
+               case QAbstractSlider::SliderSingleStepAdd:
+               case QAbstractSlider::SliderSingleStepSub:
+               case QAbstractSlider::SliderToMinimum:
+               case QAbstractSlider::SliderToMaximum:
+               case QAbstractSlider::SliderMove:
+                       scrollBufferView(verticalScrollBar()->sliderPosition());
+                       break;
+       }
 }
 
 
Index: frontends/WorkArea.C
===================================================================
--- frontends/WorkArea.C        (revision 16545)
+++ frontends/WorkArea.C        (working copy)
@@ -254,6 +254,17 @@
 }
 
 
+void WorkArea::scrollBarAction(kb_action action)
+{
+       hideCursor();
+       LCursor cur = buffer_view_->cursor();
+       lyx::dispatch(FuncRequest(action));
+       if (!lyxrc.cursor_follows_scrollbar)
+               buffer_view_->cursor() = cur;
+       toggleCursor();
+}
+
+
 void WorkArea::showCursor()
 {
        if (cursor_visible_)
Index: frontends/WorkArea.h
===================================================================
--- frontends/WorkArea.h        (revision 16545)
+++ frontends/WorkArea.h        (working copy)
@@ -14,6 +14,8 @@
 #ifndef BASE_WORKAREA_H
 #define BASE_WORKAREA_H
 
+#include "lfuns.h"
+
 #include "frontends/key_state.h"
 #include "frontends/LyXKeySym.h"
 #include "frontends/Timeout.h"
@@ -100,6 +102,8 @@
        void resizeBufferView();
        ///
        void scrollBufferView(int position);
+       ///
+       void scrollBarAction(kb_action action);
        /// hide the visible cursor, if it is visible
        void hideCursor();
        /// show the cursor if it is not visible

Reply via email to