Skip to content

Commit

Permalink
New: CPEvent scrollingDeltaX, scrollingDeltaY and hasPreciseScrolling…
Browse files Browse the repository at this point in the history
…Deltas.

Refs #2013.
  • Loading branch information
aljungberg committed Jul 23, 2014
1 parent 81f9748 commit 7470f4f
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
30 changes: 30 additions & 0 deletions AppKit/CPEvent.j
Expand Up @@ -68,6 +68,9 @@ var _CPEventPeriodicEventPeriod = 0,
float _deltaX;
float _deltaY;
float _deltaZ;
float _scrollingDeltaX;
float _scrollingDeltaY;
BOOL _hasPreciseScrollingDeltas;

#if PLATFORM(DOM)
BOOL _suppressCappuccinoCut;
Expand Down Expand Up @@ -163,7 +166,9 @@ var _CPEventPeriodicEventPeriod = 0,

// Make sure these are 0 rather than nil.
_deltaX = 0;
_scrollingDeltaX = 0;
_deltaY = 0;
_scrollingDeltaY = 0;
_deltaZ = 0;
}

Expand Down Expand Up @@ -417,6 +422,31 @@ var _CPEventPeriodicEventPeriod = 0,
return _deltaZ;
}

- (BOOL)hasPreciseScrollingDeltas
{
return !!_hasPreciseScrollingDeltas;
}

/*!
Returns the change in points on the x-axis for a mouse movement, unless hasPreciseScrollingDeltas is NO,
in which case the change is measured in number of "lines" or "rows" and needs to be multiplied as appropriate
to get change in pixels.
*/
- (float)scrollingDeltaX
{
return _scrollingDeltaX;
}

/*!
Returns the change in points on the y-axis for a mouse movement, unless hasPreciseScrollingDeltas is NO,
in which case the change is measured in number of "lines" or "columns" and needs to be multiplied as appropriate
to get change in pixels.
*/
- (float)scrollingDeltaY
{
return _scrollingDeltaY;
}

- (BOOL)_triggersKeyEquivalent:(CPString)aKeyEquivalent withModifierMask:aKeyEquivalentModifierMask
{
if (!aKeyEquivalent)
Expand Down
2 changes: 2 additions & 0 deletions Tests/AppKit/CPEventTest.j
Expand Up @@ -21,6 +21,8 @@
[self assert:0 equals:[anEvent deltaX] message:"default event delta X should be 0"];
[self assert:0 equals:[anEvent deltaY] message:"default event delta Y should be 0"];
[self assert:0 equals:[anEvent deltaZ] message:"default event delta Z should be 0"];
[self assert:0 equals:[anEvent scrollingDeltaX] message:"default event scrolling delta X should be 0"];
[self assert:0 equals:[anEvent scrollingDeltaY] message:"default event scrolling delta Y should be 0"];
}

- (void)testDescription
Expand Down

0 comments on commit 7470f4f

Please sign in to comment.