From 2cdb6fdb13211372fbb5cca180f011488cbac93e Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 8 Apr 2007 22:28:42 +0000 Subject: [PATCH] added mouse wheel support (patch 1696082) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@45340 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/changes.txt | 4 ++++ src/x11/window.cpp | 16 ++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/docs/changes.txt b/docs/changes.txt index 9256834e9e..74b77b8c3e 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -127,6 +127,10 @@ wxMSW: - Fixed infinite loop in wxThread::Wait() in console applications. - Return the restored window size from GetSize() when window is minimized. +wxX11: + +- Added mouse wheel support (David Hart) + 2.8.4 ----- diff --git a/src/x11/window.cpp b/src/x11/window.cpp index 2ebaa57dfc..a2ea6261c2 100644 --- a/src/x11/window.cpp +++ b/src/x11/window.cpp @@ -1463,6 +1463,22 @@ bool wxTranslateMouseEvent(wxMouseEvent& wxevent, wxWindow *win, Window window, eventType = wxEVT_RIGHT_DOWN; button = 3; } + else if ( xevent->xbutton.button == Button4 || + xevent->xbutton.button == Button5 ) + { + // this is the same value as used under wxMSW + static const int WHEEL_DELTA = 120; + + eventType = wxEVT_MOUSEWHEEL; + button = xevent->xbutton.button; + + wxevent.m_linesPerAction = 3; + wxevent.m_wheelDelta = WHEEL_DELTA; + + // Button 4 means mousewheel up, 5 means down + wxevent.m_wheelRotation = button == Button4 ? WHEEL_DELTA + : -WHEEL_DELTA; + } // check for a double click // TODO: where can we get this value from? -- 2.45.2