I am trying to do some interactive 2D shapes, like buttons that change color for example, in EJS.
I am having a problem with making them "clickable". If I choose the 2DShape to not be dragable, the object I make cannot be made clickable, so I can't execute functions when the user clicks on it.
The only way I have found to make them clickable is to make them dragable in either direction. If I choose "Dragable: ENABLED_NONE" they become not clickable.
Is there a way to make them clickable but not dragable?
Hum! (That's my favorite expression when someone asks for something I had not foreseen :-) )
Yes. ENABLED_NONE makes the object not insensitive to clicks.
If you enable it, you risk the user will move it in the X direction, in the Y direction, or both.
No other possibility, I am afraid. At least not yet. I would need to implement this if we find this is a good idea.
There is a workaround, though. Set the "Draggable" property to ENABLED_X. And if xPos[] is the array of the positions of the elements of the set and if you click on a given index, force the value of xPos[index] in the "On drag"action. This has the effect of repositioning the element in case the user moved it.
It's not very clean, but it should work.
If you insist, I can implement a new "Draggable" option, one that makes it responsive (i.e. clickable) but will not let the user move it at all.
I think there is a simpler way. You can define a variable lets say (v) which is the X or Y position of another object Now if you define the clickable object position X or Y indirect, lets say (v+10) it is clickable and not dragable. That is what I use in my models.