macoscocoascrollnsviewnsresponder

NSView disable smooth scrolling


I have an MTKView where I'm rendering a triangle and I want to be able to translate it using the two-finger drag gesture that calls the scrollWheel: method. The default behavior of the scrollWheel: method is to produce extra scrolling events to implement smooth scrolling that dies down over time. I'd like to disable that behavior and have a rigid scrolling that ends as soon as I lift my fingers off the trackpad. Does anyone know how to disable smooth scrolling for NSView?


Solution

  • You can check the momentumPhase property of the NSEvent parameter to determine whether to ignore the event or not.