How to I delete a placed marker?

I am using VASSAL to implement a free form miniature game.

I can select a piece, then right click to “place a movement template” in front of it. (the person can then drag the unit to be anywhere within that template which is how far it can move), this is all working fine. It even conforms to the rotation of the unit since unit can face any direction.

What I want is I want to have another right click command for when I am done to remove this movement template from the map. What is the best way to do that? Ideally I can send an event to “this” template only on the map to remove it (since there might be other movement template on the map at this time).

Any suggestions welcome, thanks in advance.

I assume you’re trying to delete the template by right-clicking and selecting an option from the main piece? In that case, use a Global Key Command (GKC) on the main piece, with a Restrict Range equal to the maximum possible distance from the center of the piece to the center of the template. You would use this to trigger a Delete trait on the template piece. If you’re using a grid, the distance is in grid units; otherwise, it’s in pixels.

This will only work properly if there’s no possibility of a second template also being within that range, of course.

The more complicated method, which would work even if multiple templates are in range, is to use a Global Property to assign a unique identifier to each template when it’s created, saving that identifier to a Dynamic Property on both the main piece and the template (and then incrementing the GP), then use a restriction on the GKC to only work on pieces with the matching ID.