Skip to content

Commit

Permalink
xrSdkControls/NumericSpinner: correct cursor accumulation
Browse files Browse the repository at this point in the history
  • Loading branch information
Xottab-DUTY committed Feb 26, 2018
1 parent 226bc9f commit b186ebf
Showing 1 changed file with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,18 @@ private void btnHSpin_MouseMove(object sender, MouseEventArgs e)
if (!isDragging || mouseX == e.X)
return;

bool increasing;
var newValue = numSpinner.Value;
if (mouseX > e.X)
{
increasing = false;
newValue -= (mouseX - e.X) * Precision;
}
else
{
increasing = true;
newValue += (e.X - mouseX) * Precision;
}

if (newValue > numSpinner.Maximum)
numSpinner.Value = numSpinner.Maximum;
Expand All @@ -117,12 +124,15 @@ private void btnHSpin_MouseMove(object sender, MouseEventArgs e)
else
numSpinner.Value = newValue;

if (accumulation > 9)
if (accumulation > 1 || accumulation < -1)
{
Cursor.Position = mousePos;
accumulation = 0;
}
++accumulation;
if (increasing)
++accumulation;
else
--accumulation;
}
}
}

0 comments on commit b186ebf

Please sign in to comment.