Using a Scrollwheel or Magic Mouse to Scroll - how?

Hi

As I was looking for possibilities to implement a scrollwheel/magic mouse touch to scroll through my imagebrowser ( on OSX) I came across some fairly old workarounds.
I figured out that GLUT doesnt send any scrollwheel events unless you patch it:
http://forum.openframeworks.cc/t/scroll-wheel-event/593/0
http://stackoverflow.com/questions/14378/using-the-mouse-scrollwheel-in-glut
http://iihm.imag.fr/blanch/howtos/MacOSXGLUTMouseWheel.html

I didnt get this patch to work, not with scrollwheel nor magic mouse. I made the changes to the glut.h but do not know what changes I should add to ofAppGlutWindow and how and what sort of event I get?
Are these patches out of date? Is there a working patch for OSX 10.7 higher?

I also found the ofxMultiTouchPad Addon which gets touches, not clicks from the magic mouse. Maybe one can use the touches as scroll event? Any experiences with that?

Thanks
Jakob

Hi
It is me again and I finally had time and could wrap my head around it.

With GLFW I finally got the scrollwheel of my mouse on mac (with the of v0.8.0 release) working.

I had to add some code in a couple of OF Files.
As I am only an c++ amateur, I am not sure if everything is correct. At least it works on mac with the of v0.8.0 release. I uploaded a zip file where you can find the files I had to change and a sample code how to get the data.

updated_OF_forScrolling.zip (22.9 KB)

Hurray
Jakob

1 Like

hi Jakob,

thanks for your effort! super awesome!!! works smooth on my machine too. perfect timing also, needed that scrollwheel badly for a current project :wink: this implementation is very clean and direct, opposed to some cocoa implementations if you just want the scroll wheel.

i would suggest to make it a pull request on the oF master branch? or let guys like @arturo or @bakercp know?

thanks! best,
arne.

(minor comment: it you would consider a pull request, would be nice to put the added lines in the exact right place in between the code lines related to mouse functions - instead of at the bottom of a block of code (which ofcourse for the zip purpose works in favor, thanks))

Hey all, this is very nice indeed. Scroll wheel support has been in and out for a little while, but I think it’s definitely time to bring it in officially. I’d definitely suggest making a pull request .

1 Like

what is the current situation with Glut though?

freeglut seems to have a

glutMouseWheelFunc(void (*func)(int, int, int, int));

anybody tried to modify glut or replace it with freeglut?

Thanks for the response. I had to read into how to make a pull request (still a bit new in this area), but now I think I am up for it.

@bakercp
In the code contribution workflow page I read:

All changes (bug fixes and feature requests) should first be submitted as issues. Pull requests for features developed without discussion or approval may not be considered.

Do I have to do that now as well?

@arne
Thanks for the code comment. You are absolutely right.

Btw: Has anyone tested it on windows?

Regarding GLUT
In my initial post, all the way up, I gathered some links from people having achieved some workarounds I think. I myself couldn’t make it work and freeglut I have never tried.

Jakob

Yeah, I think it’s clear what the goal is and the need is there. We can continue the discussion of the specific implementation issues with the issue that gets generated with the PR. So, I’d say go for it. Of course, theres a chance folks will suggest a different way to do it, but it’s always a little easier to have a discussion when code is already there … also code that is already written carries more weight than theoretical code :slight_smile:

OK I now made a pull request for the scrollwheel feature. Hope I did that one right.

As the values of apples magic mouse are way higher than the one from a standard mousewheel, I wanted to ask if you know of any possibility to detect if a magic mouse or a standard mouse is used. So one could compensate a bit.

Jakob

Hey friends, how come this was not included in 8.1?

I remember Jakob’s solution to be working fantastic on both mac and pc

oF v0.8.1 was strictly a bug fix release and the suggested change #2786 might be considered new functionality and likely breaks some existing addons (see the PR comments for more info).

ah. I see… Thank’s for the insight pitzthewiz! :beer: