On 24.03.2015 22:57 Ian MacArthur wrote:
> On Tue Mar 24 2015 18:30:56, Greg Ercolano wrote:
>>
>> On 03/24/15 10:17,
dori...@gmail.com wrote:
>>> I see there's a function called Fl::event_dy which returns mouse wheel activity.
>>> I'm guessing that this has to be called within the 'handle' function?
>>
>> Yes, look for the FL_MOUSEWHEEL event, and then you can read
>> Fl::event_dy() for the position.
>>
>> I know Fl_Scrollbar uses this; see src/Fl_Scrollbar.cxx and search
>> for FL_MOUSEWHEEL to see example use.
>>
>> Let us know if you can't get it to work.
>
>
> Yes, and though it sounds odd to say it, I really think this would be easier to do “in code” than to do in fluid...
>
> Basically, your best bet is derive your own outer window class, derived from Fl_Double_Window, than add a handle method to that to catch the mouse wheel events (all other events you need to just pass on to the base class handle in the usual way.)
>
> You can then use the mouse wheel events to update your slider widget, and hence do whatever callback operations need to be done there...
>
> Well, something like that, anyway.
You may also try to use Fl::add_handler() to get the mousewheel event if
no other widget uses it (which is probably the case). This should work
the same way as in a derived class, but doesn't need to derive a class.
http://www.fltk.org/doc-1.3/events.html
<
http://www.fltk.org/doc-1.3/group__fl__events.html#gae2d39bda7362e444afa41166c478b904>
See attached file add_handler.cxx for a working demo. Example output:
[25] Event = 19 = FL_MOUSEWHEEL, (dx,dy) = (0,1)
[26] Event = 19 = FL_MOUSEWHEEL, (dx,dy) = (0,1)
[27] Event = 19 = FL_MOUSEWHEEL, (dx,dy) = (0,-1)
[28] Event = 19 = FL_MOUSEWHEEL, (dx,dy) = (0,-1)
Note: this is a modified version of hello.cxx with FLTK copyright.
Feel free to use my additions for whatever you like.