Skip to content

Commit b186ebf

Browse files
committed
xrSdkControls/NumericSpinner: correct cursor accumulation
1 parent 226bc9f commit b186ebf

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/editors/xrSdkControls/Controls/NumericSpinner/NumericSpinner.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,18 @@ private void btnHSpin_MouseMove(object sender, MouseEventArgs e)
104104
if (!isDragging || mouseX == e.X)
105105
return;
106106

107+
bool increasing;
107108
var newValue = numSpinner.Value;
108109
if (mouseX > e.X)
110+
{
111+
increasing = false;
109112
newValue -= (mouseX - e.X) * Precision;
113+
}
110114
else
115+
{
116+
increasing = true;
111117
newValue += (e.X - mouseX) * Precision;
118+
}
112119

113120
if (newValue > numSpinner.Maximum)
114121
numSpinner.Value = numSpinner.Maximum;
@@ -117,12 +124,15 @@ private void btnHSpin_MouseMove(object sender, MouseEventArgs e)
117124
else
118125
numSpinner.Value = newValue;
119126

120-
if (accumulation > 9)
127+
if (accumulation > 1 || accumulation < -1)
121128
{
122129
Cursor.Position = mousePos;
123130
accumulation = 0;
124131
}
125-
++accumulation;
132+
if (increasing)
133+
++accumulation;
134+
else
135+
--accumulation;
126136
}
127137
}
128138
}

0 commit comments

Comments
 (0)