Automatically moving all multixy points relatively to main point

Hello,
I use a multixy-widget to control parameters whose relative position to each other matters.
I have a multixy-widget with 2 (in the future maybe more) points. My plan is that point 1 acts as the main anchor point, so all other points move relatively to to this point if the anchor is moved. If another point is touched, it should of course not be moved automatically.
I have written the following code for the multixy
onCreate:

var touchedPoints = {}
var pointOffsets = {}
var value = get(this);
for (var i=0; i<getProp(this, 'points'); i++) {
  touchedPoints[i] = false;
  pointOffsets[i] = [value[2*i] - value[0], value[2*i + 1] - value[1]]
  
}
setVar(this, 'pointOffsets', pointOffsets)
setVar(this, 'touchedPoints', touchedPoints)

onValue:

var touchedPoints = getVar(this, 'touchedPoints');
var pointOffsets = getVar(this, 'pointOffsets');


if(!touchedPoints[1])
{
value[2] = value[0] + pointOffsets[1][0]; 
value[3] = value[1] + pointOffsets[1][1];

}

set(this, value);

onTouch:

if (event.handle !== undefined) {
  var touchedPoints = getVar(this, 'touchedPoints')
  touchedPoints[event.handle] = event.type == 'start' // true or false
  setVar(this, 'touchedPoints', touchedPoints)
  
  if(event.handle > 0 && event.type == 'stop'){
    var pointOffsets = getVar(this, 'pointOffsets')
    pointOffsets[event.handle] = [value[2*event.handle] - value[0], value[2*event.handle + 1] - value[1]]
    setVar(this, 'pointOffsets', pointOffsets)
  }
}

This kinda works, but the problem is, that the secondary points are only moved on releasing the main point. When instead setting the value of a different multixy it works flawlessly, so this is what i am using as a workaround right now, but i would like to do this with a single multixy.

Has anyone encountered the same problem or knows what i did wrong? is it a racecondition when setting the value of a multixy while also still moving it?

1 Like

Values that are received while the widget is touched are queued until the gesture is over to avoid conflicts between interaction and possible feedback from the controlled application. In that particular case it seems to be irrelevant and could be changed, I'll check this out.

Thank you very much, you are doing a lot of great work with this program :slight_smile:

1 Like

This should work in v1.19.0