drag scrolling as in good old dillo1
Hi, here is a patch to enable drag scrolling with the middle mouse button as in dillo1. For me from now only the "Backspace" hotkey is missing for daily browsing - apart from the occasional crashes of course :-) Johannes diff --git a/dw/fltkviewport.cc b/dw/fltkviewport.cc --- a/dw/fltkviewport.cc +++ b/dw/fltkviewport.cc @@ -47,6 +47,7 @@ FltkViewport::FltkViewport (int x, int y vscrollbar->callback (vscrollbarCallback, this); scrollX = scrollY = 0; + dragScrolling = 0; gadgetOrientation[0] = GADGET_HORIZONTAL; gadgetOrientation[1] = GADGET_HORIZONTAL; @@ -202,6 +203,34 @@ int FltkViewport::handle (int event) /** \bug Undraw focus box. */ return 1; + case ::fltk::PUSH: + if (::fltk::event_button() == ::fltk::MiddleButton) { + dragScrolling = 1; + dragX = ::fltk::event_x(); + dragY = ::fltk::event_y(); + /* pass event so that middle click can open link in new window */ + FltkWidgetView::handle (event); + return 1; + } + break; + + case ::fltk::DRAG: + if (::fltk::event_button() == ::fltk::MiddleButton) { + if (dragScrolling) { + scroll(dragX - ::fltk::event_x(), dragY - ::fltk::event_y()); + dragX = ::fltk::event_x(); + dragY = ::fltk::event_y(); + return 1; + } + } + break; + + case ::fltk::RELEASE: + if (::fltk::event_button() == ::fltk::MiddleButton) { + dragScrolling = 0; + } + break; + case ::fltk::SHORTCUT: switch (::fltk::event_key()) { case PageUpKey: @@ -236,12 +265,9 @@ int FltkViewport::handle (int event) scrollTo (canvasWidth, canvasHeight); /* gets adjusted in scroll() */ return 1; } + } - return FltkWidgetView::handle (event); - - default: - return FltkWidgetView::handle (event); - } + return FltkWidgetView::handle (event); } // ---------------------------------------------------------------------- diff --git a/dw/fltkviewport.hh b/dw/fltkviewport.hh --- a/dw/fltkviewport.hh +++ b/dw/fltkviewport.hh @@ -21,6 +21,7 @@ private: int scrollX, scrollY; int scrollDX, scrollDY; + int dragScrolling, dragX, dragY; ::fltk::Scrollbar *vscrollbar, *hscrollbar;
On Sat, Oct 20, 2007 at 01:06:41PM +0200, Johannes Hofmann wrote:
Hi,
here is a patch to enable drag scrolling with the middle mouse button as in dillo1.
Done.
For me from now only the "Backspace" hotkey is missing for daily browsing - apart from the occasional crashes of course :-)
:-) -- Cheers Jorge.-
participants (2)
-
bogus@does.not.exist.com
-
Johannes.Hofmann@gmx.de