From 54b6360ce906296a05a81d1960a772d2be7bf0e1 Mon Sep 17 00:00:00 2001 From: Garrett Holland Date: Thu, 7 May 2026 07:55:46 -0400 Subject: [PATCH] fix: Improve mouse wheel handling for high-resolution devices (#2346) --- Aga.Controls/Tree/TreeViewAdv.Input.cs | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/Aga.Controls/Tree/TreeViewAdv.Input.cs b/Aga.Controls/Tree/TreeViewAdv.Input.cs index 57d1ecf..466a233 100644 --- a/Aga.Controls/Tree/TreeViewAdv.Input.cs +++ b/Aga.Controls/Tree/TreeViewAdv.Input.cs @@ -116,15 +116,25 @@ namespace Aga.Controls.Tree _search.EndSearch(); if (SystemInformation.MouseWheelScrollLines > 0) { - int lines = e.Delta / 120 * SystemInformation.MouseWheelScrollLines; - int newValue = _vScrollBar.Value - lines; - newValue = Math.Min(_vScrollBar.Maximum - _vScrollBar.LargeChange + 1, newValue); - newValue = Math.Min(_vScrollBar.Maximum, newValue); - _vScrollBar.Value = Math.Max(_vScrollBar.Minimum, newValue); + // Accumulate sub-120 deltas from high-resolution precision trackpads. + // Classic scroll wheels always send multiples of 120; precision devices + // send smaller values (e.g. 15) that would integer-divide to zero. + _wheelDeltaRemainder += e.Delta; + int lines = _wheelDeltaRemainder / 120 * SystemInformation.MouseWheelScrollLines; + _wheelDeltaRemainder %= 120; + if (lines != 0) + { + int newValue = _vScrollBar.Value - lines; + newValue = Math.Min(_vScrollBar.Maximum - _vScrollBar.LargeChange + 1, newValue); + newValue = Math.Min(_vScrollBar.Maximum, newValue); + _vScrollBar.Value = Math.Max(_vScrollBar.Minimum, newValue); + } } base.OnMouseWheel(e); } + private int _wheelDeltaRemainder; + protected override void OnMouseDown(MouseEventArgs e) { if (CurrentEditorOwner != null)