From 346954e17846811bc805bd92e3be1fda71dc8699 Mon Sep 17 00:00:00 2001 From: Michael R Sweet Date: Tue, 29 Nov 2005 18:06:46 +0000 Subject: [PATCH] Fix mouse wheel handling on OSX (this works with MightyMouse on OSX 10.4.3 using the standard mouse wheel event...) git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@4672 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- src/Fl_Text_Display.cxx | 3 ++- src/Fl_mac.cxx | 22 ++++------------------ 2 files changed, 6 insertions(+), 19 deletions(-) diff --git a/src/Fl_Text_Display.cxx b/src/Fl_Text_Display.cxx index 8de05f424..e95f0095e 100644 --- a/src/Fl_Text_Display.cxx +++ b/src/Fl_Text_Display.cxx @@ -3202,7 +3202,8 @@ int Fl_Text_Display::handle(int event) { } case FL_MOUSEWHEEL: - return mVScrollBar->handle(event); + if (Fl::event_dy()) return mVScrollBar->handle(event); + else return mHScrollBar->handle(event); case FL_FOCUS: case FL_UNFOCUS: diff --git a/src/Fl_mac.cxx b/src/Fl_mac.cxx index 75d1481a6..7fbc295c6 100644 --- a/src/Fl_mac.cxx +++ b/src/Fl_mac.cxx @@ -827,26 +827,11 @@ static pascal OSStatus carbonWindowHandler( EventHandlerCallRef nextHandler, Eve * Carbon Mousewheel handler * This needs to be linked into all new window event handlers */ -static pascal OSStatus carbonMousewheelHandler( EventHandlerCallRef nextHandler, EventRef ev, void *userData ) +static pascal OSStatus carbonMousewheelHandler( EventHandlerCallRef nextHandler, EventRef event, void *userData ) { // Handle the new "MightyMouse" mouse wheel events. Please, someone explain // to me why Apple changed the API on this even though the current API // supports two wheels just fine. Matthias, - EventRef event; -// fprintf(stderr, "carbonMousewheelHandler: GetEventKind(ev=%p) = %d\n", ev, -// GetEventKind(ev)); - if (GetEventKind(ev)==11) { - // if this is a "MightyMouse" event, we need to convert it into a regular - // MouseWheel event -// fputs("MightyMouse event!\n", stderr); - GetEventParameter( ev, kEventParamEventRef, typeEventRef, NULL, sizeof( EventRef ), NULL, &event ); - } else { - // otherwise, we simply copy the event... - event = ev; - } - -// fprintf(stderr, "event=%p!\n", event); - fl_lock_function(); fl_os_event = event; @@ -858,9 +843,11 @@ static pascal OSStatus carbonMousewheelHandler( EventHandlerCallRef nextHandler, GetEventParameter( event, kEventParamMouseWheelDelta, typeLongInteger, NULL, sizeof(long), NULL, &delta ); // fprintf(stderr, "axis=%d, delta=%d\n", axis, delta); if ( axis == kEventMouseWheelAxisX ) { - Fl::e_dx = delta; + Fl::e_dx = -delta; + Fl::e_dy = 0; if ( Fl::e_dx) Fl::handle( FL_MOUSEWHEEL, window ); } else if ( axis == kEventMouseWheelAxisY ) { + Fl::e_dx = 0; Fl::e_dy = -delta; if ( Fl::e_dy) Fl::handle( FL_MOUSEWHEEL, window ); } else { @@ -1783,7 +1770,6 @@ void Fl_X::make(Fl_Window* w) OSStatus ret; EventHandlerUPP mousewheelHandler = NewEventHandlerUPP( carbonMousewheelHandler ); // will not be disposed by Carbon... static EventTypeSpec mousewheelEvents[] = { -// { kEventClassMouse, 11 }, // "11" is the yet unlabled "MightyMouse" wheel event - sigh! { kEventClassMouse, kEventMouseWheelMoved } }; ret = InstallWindowEventHandler( x->xid, mousewheelHandler, (int)(sizeof(mousewheelEvents)/sizeof(mousewheelEvents[0])),