Report momentum scrolling status of scroll events on cocoa

This commit is contained in:
Kovid Goyal 2018-12-26 11:03:36 +05:30
parent fdbd8df7b2
commit fc5e74e457
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 17 additions and 1 deletions

View File

@ -923,6 +923,17 @@ - (void)scrollWheel:(NSEvent *)event
if (yscale > 0) deltaY *= yscale;
}
switch([event momentumPhase]) {
case NSEventPhaseBegan:
flags |= (1 << 1); break;
case NSEventPhaseChanged:
flags |= (2 << 1); break;
case NSEventPhaseEnded:
flags |= (3 << 1); break;
default:
break;
}
if (fabs(deltaX) > 0.0 || fabs(deltaY) > 0.0)
_glfwInputScroll(window, deltaX, deltaY, flags);
}

7
glfw/glfw3.h vendored
View File

@ -1380,7 +1380,12 @@ typedef void (* GLFWcursorenterfun)(GLFWwindow*,int);
* @param[in] window The window that received the event.
* @param[in] xoffset The scroll offset along the x-axis.
* @param[in] yoffset The scroll offset along the y-axis.
* @param[in] flags A bit-mask providing extra data about the event. flags & 1 will be true if and only if the offset values are "high-precision". Typically pixel values. Otherwise the offset values are number of lines.
* @param[in] flags A bit-mask providing extra data about the event.
* flags & 1 will be true if and only if the offset values are "high-precision".
* Typically pixel values. Otherwise the offset values are number of lines.
* (flags >> 1) & 3 will have value 1 for start of momentum scrolling,
* value 2 for momentum scrolling in progress and value 3 for momentum
* scrolling ended.
*
* @sa @ref scrolling
* @sa @ref glfwSetScrollCallback