Author: bgbnbigben
Date: 2011-10-30 05:59:11 -0700 (Sun, 30 Oct 2011)
New Revision: 9160
Log:
Added a patch (#2746) to add support for keyboard in the scrollgroup. Many 
thanks to Winfreid Szukalski for this patch.


Modified:
   trunk/src/ScrollGroup.cxx

Modified: trunk/src/ScrollGroup.cxx
===================================================================
--- trunk/src/ScrollGroup.cxx   2011-10-29 15:04:37 UTC (rev 9159)
+++ trunk/src/ScrollGroup.cxx   2011-10-30 12:59:11 UTC (rev 9160)
@@ -518,7 +518,100 @@
       }
     }
 
-  case KEY:
+  case SHORTCUT:
+   {
+#define CURSOR_STEP 8
+       int scroll_x = hscrollbar.value();
+       int scroll_y = scrollbar.value();
+
+       if(hscrollbar.visible())
+  {
+       if(event_key() == LeftKey)
+ {
+       if(scroll_x == 0) return 1;
+
+       if((scroll_x = hscrollbar.value() - CURSOR_STEP) < 0) scroll_x = 0;
+
+       scrollTo(scroll_x, scroll_y);
+
+       return 1;
+ }
+       if(event_key() == RightKey) 
+ {
+       if(scroll_x == max_x_scroll_) return 1;
+
+       if((scroll_x = hscrollbar.value() + CURSOR_STEP) > max_x_scroll_) 
+        scroll_x = max_x_scroll_;
+
+       scrollTo(scroll_x, scroll_y);
+
+       return 1;
+ }
+  }
+       if(scrollbar.visible())
+  {
+       if(event_key() == UpKey)
+ {
+       if(scroll_y == 0) return 1;
+
+       if((scroll_y = scrollbar.value() - CURSOR_STEP) < 0) scroll_y = 0;
+
+       scrollTo(scroll_x,scroll_y);
+
+       return 1;
+ }
+       if(event_key() == DownKey)
+ {
+       if(scroll_y == max_y_scroll_) return 1;
+
+       if((scroll_y = scrollbar.value() + CURSOR_STEP) > max_y_scroll_) 
+        scroll_y = max_y_scroll_;
+
+       scrollTo(scroll_x,scroll_y);
+
+       return 1;
+ }
+       if(event_key() == HomeKey)
+ {
+       if(scroll_y > 0)
+        scrollTo(scroll_x, 0);
+
+       return 1;
+ }
+       if(event_key() == EndKey)
+ {
+       if(scroll_y < max_y_scroll_)
+        scrollTo(scroll_x, max_y_scroll_);
+
+       return 1;
+ }
+       if(event_key() == PageUpKey)
+ {
+       if(scroll_y == 0) return 1;
+
+       if((scroll_y = scrollbar.value() - scrollbar.pagesize()) < 0) 
+        scroll_y = 0;
+
+       scrollTo(scroll_x, scroll_y);
+
+       return 1;
+ }
+       if(event_key() == PageDownKey)
+ {
+       if(scroll_y == max_y_scroll_) return 1;
+
+       if((scroll_y = scrollbar.value() + scrollbar.pagesize()) > 
max_y_scroll_)
+        scroll_y = max_y_scroll_;
+
+       scrollTo(scroll_x, scroll_y);
+
+       return 1;
+ }
+  }
+   }
+       break;
+
+  case KEY: 
     if (scrollbar.send(event)) return 1;
     if (hscrollbar.send(event)) return 1;
     break;

_______________________________________________
fltk-commit mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-commit

Reply via email to