Fl_Roller can now be controlled via the mouse wheel (STR #3120).

This commit is contained in:
Matthias Melcher 2019-02-04 23:12:02 +01:00
parent 67f0bf6fee
commit 0cac8d52e3
3 changed files with 67 additions and 46 deletions

View File

@ -102,6 +102,7 @@ Changes in FLTK 1.4.0 Released: ??? ?? 2019
Other Improvements Other Improvements
- (add new items here) - (add new items here)
- Fl_Roller can now be controlled via the mouse wheel (STR #3120).
- Tooltips hide by themselves after 12 seconds (STR #2584). - Tooltips hide by themselves after 12 seconds (STR #2584).
- Added widget visibility indicator to Fluid (STR #2669). - Added widget visibility indicator to Fluid (STR #2669).
- Added Fl_Input_::append() method (STR #2953). - Added Fl_Input_::append() method (STR #2953).

View File

@ -29,6 +29,11 @@
/** /**
The Fl_Roller widget is a "dolly" control commonly used to The Fl_Roller widget is a "dolly" control commonly used to
move 3D objects. move 3D objects.
The Roller can be controlled by clicking an ddragging the mouse, by the
corresponding arrow keys when the roller has the keyboard focus, or by the
mousewheels when the mouse pointer is positioned over the roller widget.
<P ALIGN=CENTER>\image html Fl_Roller.png <P ALIGN=CENTER>\image html Fl_Roller.png
\image latex Fl_Roller.png "Fl_Roller" width=4cm \image latex Fl_Roller.png "Fl_Roller" width=4cm
*/ */

View File

@ -41,6 +41,21 @@ int Fl_Roller::handle(int event) {
case FL_RELEASE: case FL_RELEASE:
handle_release(); handle_release();
return 1; return 1;
case FL_MOUSEWHEEL :
if (Fl::belowmouse()==this) {
if (horizontal()) {
if (Fl::e_dx!=0) {
handle_drag(clamp(round(increment(value(),-Fl::e_dx))));
}
} else {
if (Fl::e_dy!=0) {
handle_drag(clamp(round(increment(value(),-Fl::e_dy))));
}
}
return 1;
} else {
return 0;
}
case FL_KEYBOARD : case FL_KEYBOARD :
switch (Fl::event_key()) { switch (Fl::event_key()) {
case FL_Up: case FL_Up: