macOS expose scroll invertion in event
applied patch from #18358, thanks for the patch Andy
This commit is contained in:
@@ -1801,6 +1801,10 @@ public:
|
||||
// should occur for each delta.
|
||||
int GetWheelDelta() const { return m_wheelDelta; }
|
||||
|
||||
// On Mac, has the user selected "Natural" scrolling in their System
|
||||
// Preferences? Currently false on all other OS's.
|
||||
bool IsWheelInverted() const { return m_wheelInverted; }
|
||||
|
||||
// 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).
|
||||
@@ -1834,6 +1838,7 @@ public:
|
||||
wxMouseWheelAxis m_wheelAxis;
|
||||
int m_wheelRotation;
|
||||
int m_wheelDelta;
|
||||
bool m_wheelInverted;
|
||||
int m_linesPerAction;
|
||||
int m_columnsPerAction;
|
||||
float m_magnification;
|
||||
|
@@ -2795,6 +2795,22 @@ public:
|
||||
*/
|
||||
int GetWheelDelta() const;
|
||||
|
||||
/**
|
||||
On Mac, has the user selected "Natural" scrolling in their System
|
||||
Preferences? Currently false on all other OS's.
|
||||
|
||||
"Natural" scrolling means that content scrolling happens in the
|
||||
opposite direction, and if you are indeed scrolling content then
|
||||
you don't need to use this function because macOS has already
|
||||
inverted the scroll direction.
|
||||
But there can be special situations where you want the mouse wheel
|
||||
action to work always in the same direction and in that case you
|
||||
will need this function.
|
||||
|
||||
@since 3.1.3
|
||||
*/
|
||||
bool IsWheelInverted() const;
|
||||
|
||||
/**
|
||||
Get wheel rotation, positive or negative indicates direction of rotation.
|
||||
|
||||
|
@@ -708,9 +708,10 @@ void MyCanvas::OnMouseWheel( wxMouseEvent &event )
|
||||
int x,y;
|
||||
CalcUnscrolledPosition( pt.x, pt.y, &x, &y );
|
||||
wxLogMessage( "Mouse wheel event at: %d %d, scrolled: %d %d\n"
|
||||
"Rotation: %d, delta = %d",
|
||||
"Rotation: %d, delta: %d, inverted: %d",
|
||||
pt.x, pt.y, x, y,
|
||||
event.GetWheelRotation(), event.GetWheelDelta() );
|
||||
event.GetWheelRotation(), event.GetWheelDelta(),
|
||||
event.IsWheelInverted() );
|
||||
|
||||
event.Skip();
|
||||
}
|
||||
|
@@ -577,6 +577,7 @@ wxMouseEvent::wxMouseEvent(wxEventType commandType)
|
||||
m_wheelAxis = wxMOUSE_WHEEL_VERTICAL;
|
||||
m_wheelRotation = 0;
|
||||
m_wheelDelta = 0;
|
||||
m_wheelInverted = false;
|
||||
m_linesPerAction = 0;
|
||||
m_columnsPerAction = 0;
|
||||
m_magnification = 0.0f;
|
||||
@@ -601,6 +602,7 @@ void wxMouseEvent::Assign(const wxMouseEvent& event)
|
||||
|
||||
m_wheelRotation = event.m_wheelRotation;
|
||||
m_wheelDelta = event.m_wheelDelta;
|
||||
m_wheelInverted = event.m_wheelInverted;
|
||||
m_linesPerAction = event.m_linesPerAction;
|
||||
m_columnsPerAction = event.m_columnsPerAction;
|
||||
m_wheelAxis = event.m_wheelAxis;
|
||||
|
@@ -719,9 +719,10 @@ void wxWidgetCocoaImpl::SetupMouseEvent( wxMouseEvent &wxevent , NSEvent * nsEve
|
||||
}
|
||||
|
||||
wxevent.m_wheelDelta = 10;
|
||||
wxevent.m_wheelInverted = [nsEvent isDirectionInvertedFromDevice];
|
||||
wxevent.m_linesPerAction = 1;
|
||||
wxevent.m_columnsPerAction = 1;
|
||||
|
||||
|
||||
if ( fabs(deltaX) > fabs(deltaY) )
|
||||
{
|
||||
// wx conventions for horizontal are inverted from vertical (originating from native msw behavior)
|
||||
|
Reference in New Issue
Block a user