I am using a for loop to render multiple text boxes to the canvas. This is the code inside that loop to draw the elements:
ctx.strokeRect(choiceStartPositionX - 3, choiceStartPositionY - 5, textLength.width + 6, lineHeight + 5);
ctx.fillText(textDescription, choiceStartPositionX, choiceStartPositionY);
But next I want to let the user click and drag the individual text boxes to move them.
I assume the rectangle and text drawn to the canvas need to be associated in some way (some kind of identifier to match them?), as well as to not have the same identifier as the other text boxes so that they don’t get dragged.
Could someone please help by showing how to do that, or a more suitable approach?