Skip to content

Commit

Permalink
Related to Issue #813: fix behaviour of UIImageSwitch in case of touc…
Browse files Browse the repository at this point in the history
…h automation: the value will return to original AFTER the mouse is released.

The general rule seems to be that endParamEdit should be called in onStopDrag.
  • Loading branch information
Guillaume Piolat committed Nov 23, 2023
1 parent 9068e89 commit 6b84c1e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions flatwidgets/dplug/flatwidgets/flatswitch.d
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,13 @@ nothrow:
{
_param.beginParamEdit();
_param.setFromGUI(_param.defaultValue());
_param.endParamEdit();
}
else
{
// Any click => invert
// Note: double-click doesn't reset to default, would be annoying
_param.beginParamEdit();
_param.setFromGUI(!_param.value());
_param.endParamEdit();
}
return Click.startDrag;
}
Expand All @@ -136,6 +134,10 @@ nothrow:

override void onStopDrag()
{
// End parameter edit at end of dragging, even if no parameter change happen,
// so that touch automation restore previous parameter value at the end of the mouse
// gesture.
_param.endParamEdit();
}

override void onMouseDrag(int x, int y, int dx, int dy, MouseState mstate)
Expand Down

0 comments on commit 6b84c1e

Please sign in to comment.