Multi XY current point selection

Hi,
is there any way to know which point is currently, moved / touch / selected ?

1 Like

Something like this should do

// onCreate:
var touchedPoints = {}
for (var i=0; i<getProp(this, 'points'); i++) {
  touchedPoints[i] = false
}
setVar(this, 'touchedPoints', touchedPoints)
// onTouch
if (event.handle !== undefined) {
  var touchedPoints = getVar(this, 'touchedPoints')
  touchedPoints[event.handle] = event.type == 'start' // true or false
  setVar(this, 'touchedPoints', touchedPoints)
}
// any scripting property
var multixyTouchedPoints = getVar('mulixy_id', 'touchedPoints')
var point0Touched = multixyTouchedPoints[0]

thanks for your reply, this one need some study.
When you say:

// any scripting property
var multixyTouchedPoints = getVar('mulixy_id', 'touchedPoints')
var point0Touched = multixyTouchedPoints[0]

Does it means to paste this script in a script widget onValue or ?
I tried and get "true"
testMulti.json (6.4 KB)
.

we are agree that this is not possible :
setVar('button_2', 'colorWidget', '#2365a7' )

Why ? It is possible, just note that this wont affect the colorWidget property but the custom variable named colorWidget which can be read using getVar or with the VAR{} syntax.

Does it means to paste this script in a script widget onValue or ?

It just depends on what you want to do with that touch information. In your session it doesn't work because you update the text widget from the pad's onValue script which is not triggered upon touch release. The script widget in your session is useless as never receives any event that would trigger its code.

Yes, I'm using VAR{} quiet often.
But in your script I was 'surprised' that with the declaration of :
var touchedPoints = {}

I managed to do what I wanted :

//onValue
var multixyTouchedPoints = getVar('multixy_1', 'touchedPoints')
var point1Touched = multixyTouchedPoints[0]
 
if (point1Touched === true){
  var src1 = get('switch_srcMulti1')
  send('/adm/obj/' + src1 + '/xy', value[0], value[1])
}
//onTouch
var multixyTouchedPoints = getVar('multixy_1', 'touchedPoints')
var point1Touched = multixyTouchedPoints[0]

if (point1Touched === true){
  var src = get('switch_srcMulti1')
    if (event.type == 'start')
    {
    send('/adm/obj/' + src + '/xy', 'touch')
    send('/adm/obj/' + src + '/select', 1)
    }
    else if (event.type == 'stop')
    {
    send('/adm/obj/' + src + '/xy', 'release')
    send('/adm/obj/' + src + '/select', 0)
    }
}

Thank you so much for your help !

1 Like