How to - implement a button on a board ?

Hi all, this is a question.

[b]How would you implement a button on a board ?

[/b]Do you have a game module with such an implementation available for looking at your code ?
I think of 2 possible buttons : press and remained pressed / press and immediate release

If the button is pressed, how do you change it’s color/border ?

Should it be a piece that can’t move but with some additional options to change it’s image once activated/pressed ?

Thanks for your ideas/suggestions/code.

Solution :
Create a GP in the Map
->In fact, this is the GP you want to act on, so you probably alredy have it
Optionaly, create a Modifier GP
That’s another GP, called Modifier, for which you can define a positive value, and that would be added to or taken from the other GP when you click on the button created just after …

Create an At-Start Stack
→ create a single piece in that stack
–>the basic piece being the image of the button you want to use
–>Action button defines the size of the button interactivity, and the Invoke Key Command to call the GP you want to act on
→ does not stack : select piece normally, never move (so your button stays in position)
–>set global property : using the GP you created first, locate in current map, with a Key Commands that will do the math.
For example, my button acts by adding +1 to the GP. It’s called by the Key Command mentioned in the Action Button, with a type of increment numeric value, increment by 1 … or Set value directly, with a New value of the GP name + a GP modifier

This way, you can have a nice button, acting as you wish on your GP.

Optionaly, you can place a layer in the single piece definition, showing a different view of the button when it’s pressed. However, this means you want the button to remain pressed and hold, ans it will probably execute the calculation in the set global property definition each time you click on it, even if it’s to release the button.

Maybe some additional test can be done so it can be pushed and released without acting twice.

thank you - I’m new to VASSAL coding but this just helped a lot.

I got over the “pushed twice” problem by the game piece cloning and then deleting itself after calling the “button press logic”. This takes the focus away from the button game piece, so it has to be clicked on again.