Fix spin controls getting applied multiple times.

When a spin control is at min or max value, pressing the arrow key to
switch to the next nonexiting value executes the callback function. That
is confusing.

Example: 'freelook' is set to 'no'. The user presses left arrow,
switching to the nonexiting value before no. The code handles the
case and resets the current value drom -1 to 0. Nevertheless the
callback is executed and switches 'freelook' from no to yes...

Fix that by not executing the callback when we're at min or max value.

Closes #884.
This commit is contained in:
Yamagi 2022-09-04 18:18:58 +02:00
parent 98a4522b1b
commit a44de1596d

View file

@ -729,10 +729,12 @@ SpinControl_DoSlide(menulist_s *s, int dir)
if (s->curvalue < 0)
{
s->curvalue = 0;
return;
}
else if (s->itemnames[s->curvalue] == 0)
{
s->curvalue--;
return;
}
if (s->generic.callback)