@@ -280,6 +280,38 @@ - (void)doCommandBySelector:(SEL)sel
280
280
281
281
- (void )scrollWheel : (NSEvent *)event
282
282
{
283
+ float dx = 0 ;
284
+ float dy = 0 ;
285
+
286
+ #if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_7
287
+ if ([event hasPreciseScrollingDeltas ]) {
288
+ NSSize cellSize = [textView cellSize ];
289
+ float thresholdX = cellSize.width ;
290
+ float thresholdY = cellSize.height ;
291
+ scrollingDeltaX += [event scrollingDeltaX ];
292
+ if (fabs (scrollingDeltaX) > thresholdX) {
293
+ dx = roundf (scrollingDeltaX / thresholdX);
294
+ scrollingDeltaX -= thresholdX * dx;
295
+ }
296
+ scrollingDeltaY += [event scrollingDeltaY ];
297
+ if (fabs (scrollingDeltaY) > thresholdY) {
298
+ dy = roundf (scrollingDeltaY / thresholdY);
299
+ scrollingDeltaY -= thresholdY * dy;
300
+ }
301
+ } else {
302
+ scrollingDeltaX = 0 ;
303
+ scrollingDeltaY = 0 ;
304
+ dx = [event scrollingDeltaX ];
305
+ dy = [event scrollingDeltaY ];
306
+ }
307
+ #else
308
+ dx = [event deltaX ];
309
+ dy = [event deltaY ];
310
+ #endif
311
+
312
+ if (dx == 0 && dy == 0 )
313
+ return ;
314
+
283
315
if ([self hasMarkedText ]) {
284
316
// We must clear the marked text since the cursor may move if the
285
317
// marked text moves outside the view as a result of scrolling.
@@ -288,11 +320,6 @@ - (void)scrollWheel:(NSEvent *)event
288
320
[[NSTextInputContext currentInputContext ] discardMarkedText ];
289
321
}
290
322
291
- float dx = [event deltaX ];
292
- float dy = [event deltaY ];
293
- if (dx == 0 && dy == 0 )
294
- return ;
295
-
296
323
int row, col;
297
324
NSPoint pt = [textView convertPoint: [event locationInWindow ] fromView: nil ];
298
325
if ([textView convertPoint: pt toRow: &row column: &col]) {
0 commit comments