diff --git a/docs/changes.txt b/docs/changes.txt index 3319dd013b..ebbe812abc 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -480,6 +480,7 @@ All: All (GUI): - Added strike-through support to wxFont (Igor Korot). +- Add support for horizontal mouse wheel events to MSW and GTK (Lauri Nurmi). - Fix infinite loop in wxHtmlEasyPrinting when trying to page break images taller than the page height in wxHtmlEasyPrinting (Laurent Poujoulat). - Added wxFilePickerCtrl::SetInitialDirectory(). @@ -521,7 +522,6 @@ MSW: - Add wxActiveXContainer::QueryClientSiteInterface and implement it in wxWebViewIE to improve the default behaviour (Allonii). - Update stretchable spaces in wxToolBar after tool removal (Catalin Raceanu). -- Add support for horizontal mouse wheel events (Lauri Nurmi). - Implement wxGraphicsContext::SetInterpolationQuality() (Eric Jensen). - Fix coordinate handling in wxDC::Blit() when source DC is a DIB. - Fix handling of composite windows in wxToolTip (Armel Asselin). diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index b8734c412d..ac10b6fc7d 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -1641,22 +1641,43 @@ window_scroll_event_hscrollbar(GtkWidget*, GdkEventScroll* gdk_event, wxWindow* static gboolean window_scroll_event(GtkWidget*, GdkEventScroll* gdk_event, wxWindow* win) { - if (gdk_event->direction != GDK_SCROLL_UP && - gdk_event->direction != GDK_SCROLL_DOWN) - { - return false; - } - wxMouseEvent event(wxEVT_MOUSEWHEEL); InitMouseEvent(win, event, gdk_event); // FIXME: Get these values from GTK or GDK event.m_linesPerAction = 3; event.m_wheelDelta = 120; - if (gdk_event->direction == GDK_SCROLL_UP) - event.m_wheelRotation = 120; - else - event.m_wheelRotation = -120; + + // Determine the scroll direction. + switch (gdk_event->direction) + { + case GDK_SCROLL_UP: + case GDK_SCROLL_RIGHT: + event.m_wheelRotation = 120; + break; + + case GDK_SCROLL_DOWN: + case GDK_SCROLL_LEFT: + event.m_wheelRotation = -120; + break; + + default: + return false; // Unknown/unhandled direction + } + + // And the scroll axis. + switch (gdk_event->direction) + { + case GDK_SCROLL_UP: + case GDK_SCROLL_DOWN: + event.m_wheelAxis = wxMOUSE_WHEEL_VERTICAL; + break; + + case GDK_SCROLL_LEFT: + case GDK_SCROLL_RIGHT: + event.m_wheelAxis = wxMOUSE_WHEEL_HORIZONTAL; + break; + } if (win->GTKProcessEvent(event)) return TRUE;