diff --git a/include/wx/event.h b/include/wx/event.h index 16f91819d9..8303647c39 100644 --- a/include/wx/event.h +++ b/include/wx/event.h @@ -1448,6 +1448,12 @@ private: wxEVT_RIGHT_DCLICK */ +enum wxMouseWheelAxis +{ + wxMOUSE_WHEEL_VERTICAL, + wxMOUSE_WHEEL_HORIZONTAL +}; + class WXDLLIMPEXP_CORE wxMouseEvent : public wxEvent, public wxMouseState { @@ -1535,10 +1541,10 @@ public: // should occur for each delta. int GetWheelDelta() const { return m_wheelDelta; } - // Gets the axis the wheel operation concerns, 0 being the y axis as on - // most mouse wheels, 1 is the x axis for things like MightyMouse scrolls - // or horizontal trackpad scrolling - int GetWheelAxis() const { return m_wheelAxis; } + // Gets the axis the wheel operation concerns; wxMOUSE_WHEEL_VERTICAL + // (most common case) or wxMOUSE_WHEEL_HORIZONTAL (for horizontal scrolling + // using e.g. a trackpad). + wxMouseWheelAxis GetWheelAxis() const { return m_wheelAxis; } // Returns the configured number of lines (or whatever) to be scrolled per // wheel action. Defaults to one. @@ -1560,7 +1566,7 @@ public: public: int m_clickCount; - int m_wheelAxis; + wxMouseWheelAxis m_wheelAxis; int m_wheelRotation; int m_wheelDelta; int m_linesPerAction; diff --git a/interface/wx/event.h b/interface/wx/event.h index dce4ea1d60..56193eda9f 100644 --- a/interface/wx/event.h +++ b/interface/wx/event.h @@ -2187,6 +2187,16 @@ public: wxClipboardTextEvent(wxEventType commandType = wxEVT_NULL, int id = 0); }; +/** + Possible axis values for mouse wheel scroll events. + + @since 2.9.4 + */ +enum wxMouseWheelAxis +{ + wxMOUSE_WHEEL_VERTICAL, ///< Vertical scroll event. + wxMOUSE_WHEEL_HORIZONTAL ///< Horizontal scroll event. +}; /** @@ -2440,12 +2450,16 @@ public: int GetWheelRotation() const; /** - Gets the axis the wheel operation concerns; @c 0 is the Y axis as on - most mouse wheels, @c 1 is the X axis. + Gets the axis the wheel operation concerns. - Note that only some models of mouse have horizontal wheel axis. + Usually the mouse wheel is used to scroll vertically so @c + wxMOUSE_WHEEL_VERTICAL is returned but some mice (and most trackpads) + also allow to use the wheel to scroll horizontally in which case + @c wxMOUSE_WHEEL_HORIZONTAL is returned. + + Notice that before wxWidgets 2.9.4 this method returned @c int. */ - int GetWheelAxis() const; + wxMouseWheelAxis GetWheelAxis() const; /** Returns @true if the event was a mouse button event (not necessarily a button diff --git a/src/common/event.cpp b/src/common/event.cpp index ce1e145c79..9896674c61 100644 --- a/src/common/event.cpp +++ b/src/common/event.cpp @@ -554,10 +554,10 @@ wxMouseEvent::wxMouseEvent(wxEventType commandType) m_clickCount = -1; + m_wheelAxis = wxMOUSE_WHEEL_VERTICAL; m_wheelRotation = 0; m_wheelDelta = 0; m_linesPerAction = 0; - m_wheelAxis = 0; } void wxMouseEvent::Assign(const wxMouseEvent& event) diff --git a/src/osx/carbon/nonownedwnd.cpp b/src/osx/carbon/nonownedwnd.cpp index dd0e3d774d..7daa2bf9f5 100644 --- a/src/osx/carbon/nonownedwnd.cpp +++ b/src/osx/carbon/nonownedwnd.cpp @@ -547,7 +547,7 @@ WXDLLEXPORT void SetupMouseEvent( wxMouseEvent &wxevent , wxMacCarbonEvent &cEve wxevent.m_wheelDelta = 1; wxevent.m_linesPerAction = 1; if ( axis == kEventMouseWheelAxisX ) - wxevent.m_wheelAxis = 1; + wxevent.m_wheelAxis = wxMOUSE_WHEEL_HORIZONTAL; } break ; diff --git a/src/osx/cocoa/window.mm b/src/osx/cocoa/window.mm index 39a737650a..d6832303c6 100644 --- a/src/osx/cocoa/window.mm +++ b/src/osx/cocoa/window.mm @@ -633,7 +633,7 @@ void wxWidgetCocoaImpl::SetupMouseEvent( wxMouseEvent &wxevent , NSEvent * nsEve if ( fabs(deltaX) > fabs(deltaY) ) { - wxevent.m_wheelAxis = 1; + wxevent.m_wheelAxis = wxMOUSE_WHEEL_HORIZONTAL; wxevent.m_wheelRotation = (int)deltaX; } else