changeset 2089:8c0772fac825

A form widget below the scrollbar was taking the latter's events (fixed)
author Jorge Arellano Cid <jcid@dillo.org>
date Mon, 13 Jun 2011 14:14:14 -0400
parents e555a2491c8c
children 4341dedfede7
files dw/fltkviewport.cc dw/fltkviewport.hh
diffstat 2 files changed, 26 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/dw/fltkviewport.cc	Sun Jun 12 16:48:45 2011 +0000
+++ b/dw/fltkviewport.cc	Mon Jun 13 14:14:14 2011 -0400
@@ -65,7 +65,7 @@
    add (vscrollbar);
 
    scrollX = scrollY = scrollDX = scrollDY = 0;
-   dragScrolling = 0;
+   horScrolling = verScrolling = dragScrolling = 0;
 
    gadgetOrientation[0] = GADGET_HORIZONTAL;
    gadgetOrientation[1] = GADGET_HORIZONTAL;
@@ -225,11 +225,6 @@
 {
    _MSG("FltkViewport::handle %d\n", event);
 
-   if (!dragScrolling &&
-       ((vscrollbar->visible() && Fl::event_inside(vscrollbar)) ||
-        (hscrollbar->visible() && Fl::event_inside(hscrollbar))))
-      return Fl_Group::handle(event);
-
    switch(event) {
    case FL_KEYBOARD:
       /* Tell fltk we want to receive KEYBOARD events as SHORTCUT.
@@ -248,7 +243,13 @@
       break;
 
    case FL_PUSH:
-      if (FltkWidgetView::handle (event) == 0 &&
+      if (vscrollbar->visible() && Fl::event_inside(vscrollbar)) {
+         if (vscrollbar->handle(event))
+            verScrolling = 1;
+      } else if (hscrollbar->visible() && Fl::event_inside(hscrollbar)) {
+         if (hscrollbar->handle(event))
+            horScrolling = 1;
+      } else if (FltkWidgetView::handle (event) == 0 &&
           Fl::event_button() == FL_MIDDLE_MOUSE) {
          /* pass event so that middle click can open link in new window */
          dragScrolling = 1;
@@ -260,13 +261,17 @@
       break;
 
    case FL_DRAG:
-      if (Fl::event_button() == FL_MIDDLE_MOUSE) {
-         if (dragScrolling) {
-            scroll(dragX - Fl::event_x(), dragY - Fl::event_y());
-            dragX = Fl::event_x();
-            dragY = Fl::event_y();
-            return 1;
-         }
+      if (dragScrolling && Fl::event_button() == FL_MIDDLE_MOUSE) {
+         scroll(dragX - Fl::event_x(), dragY - Fl::event_y());
+         dragX = Fl::event_x();
+         dragY = Fl::event_y();
+         return 1;
+      } else if (verScrolling) {
+         vscrollbar->handle(event);
+         return 1;
+      } else if (horScrolling) {
+         hscrollbar->handle(event);
+         return 1;
       }
       break;
 
@@ -278,6 +283,12 @@
       if (Fl::event_button() == FL_MIDDLE_MOUSE) {
          dragScrolling = 0;
          setCursor (core::style::CURSOR_DEFAULT);
+      } else if (verScrolling && vscrollbar->handle(event)) {
+         verScrolling = 0;
+         return 1;
+      } else if (horScrolling && hscrollbar->handle(event)) {
+         horScrolling = 0;
+         return 1;
       }
       break;
 
--- a/dw/fltkviewport.hh	Sun Jun 12 16:48:45 2011 +0000
+++ b/dw/fltkviewport.hh	Mon Jun 13 14:14:14 2011 -0400
@@ -22,6 +22,7 @@
    int scrollX, scrollY;
    int scrollDX, scrollDY;
    int dragScrolling, dragX, dragY;
+   int horScrolling, verScrolling;
 
    Fl_Scrollbar *vscrollbar, *hscrollbar;