How to simulate a "Button" on the map

Hi

I’m new to VASSAL module making but I’ve successfully made a “San Marco” module which I’ll upload once it’s been tested in earnest.

There is one final hurdle I want to leap before I consider it “finished”. I’m not a big fan of buttons in the top bar that are to do with the gameplay itself ( the one’s at the top I prefer to be about VASSAL management - server connection, zoom, undo etc. ). So I have a button I’ve simulated on the board.

It is a selectable, unmovable piece in an AT-START stack. At the moment with a GLOBAL_KEY_COMMAND it does what I want it to do however it has to be RIGHT-CLICKED and the GCK chosen from the menu to “do” what it does.

I would like it to fire the GCK each time it is LEFT-CLICKED. Is there any way of getting VASSAL to fire a TRIGGER or GCK as soon as a piece is LEFT-CLICKED ? And if so, it would have to fire again if it was LEFT-CLICKED again, even if already selected.

Thanks

With a bit of furtling in this forum I’ve answered my own questions. For those who might want to do the same:

Create a game-piece with “Does not stack” trait of select-normally but move-piece set to never.

Give it an icon that you want on the “board button” in its Basic Piece trait.

Give it an Action Button trait of the same size of the icon you chose. Make sure the Action Button trait is bottom of the trait list. Set the Action Button “invoke key command” to a unique string such as; do_my_button

Create a Global Key Command trait above the Action Button trait. Give it the key command you used above ( do_my_button ) and make it issue a Global Key Command you will use to start a Trigger e.g. call_my_button_trigger

Create a Trigger Action trait above the Global Key Command. Give it the keyboard command you specified above ( call_my_button_trigger ). In the “perform these keystrokes” list of the trigger, list various strings of things you want to happen when the button is clicked e.g. do_step_1, do_step_2 etc. Then create these as new Global Key Command traits above the Trigger Action trait.

Now you could leave it there, but to ensure double-clicking the button is kept to a minimum we are going to remove focus from the piece after it is clicked once. We will do this by cloning the button underneath itself and then deleting the original button piece. This removes focus. To do this go back to your original Trigger Action trait and add two steps at the bottom after the commands you wanted your button to do: clone_my_button and delete_my_button.

The next part is a bit indirect - you need to specify Global-Key-Commands inbetween the Trigger and the Clone/Delete traits ( not sure why - I think it’s to do with using strings for calling instead of hotkeys ). So… create a Global-Key-Command above the Trigger and in its “keyboard command” put what you put in the trigger list ( clone_my_button ) and in the “global key command” put a string like make_the_clone
Now add a Clone trait above this Global-Key-Command and give it the keyboard command you just specified ( make_the_clone ).

Do the same as the cloning step for the Delete step with a Global-Key-Command trait and a Delete trait using strings such as delete_my_button and do_the_delete
However in the Global-Key-Command you also need to put {$Selected$ == “true”} in the “Matching Properties”, otherwise your new clone will be deleted as well as the original button.

Finally make an At-Start-Stack on your map board with this game-piece in it placed where you want it on the board.

A good summary. I doubt I would have ever thought of the cloning idea! But my problem tends to be that buttons sporadically ignore clicks, not that they click twice.

Yes, I’ve noticed sometimes “board buttons” miss a click - maybe it is a weakness of detection of the “Action Button” area when a piece is first selected ?

The mouse detection is very sensitive and frequently mistakes a click for “a short drag”.

Aha…

Hello,

Would this solution work to open another map from a “button” click from the map?
I’m trying to have something like a “submap”, basically you’d click on a “card” element, that would open another map containing decks related to that “card” but I have like 0 idea/experience how to do that

Thanks,
-O.

To open another map window, you first need to assign the map window a hotkey – you need to check the “Include toolbar button to show-hide” box in the map’s configuration. This then requires you to save the module out and reload in the editor to have it functioning. You can then set the actual toolbar button’s text & image to be null, so that nothing actually appears “on the toolbar” if you want (or you can leave it there so you can open it from there too - your choice). But give the button a hotkey on the “Hotkey:” line.

Then, for your button on the main map, define a piece and give it an Action Button to click on. The keystroke it fires should then be used to activate a second trait you add to the piece, “Global Hotkey” (not to be confused with Global Key Command), and the hotkey you activate should be the hotkey you assigned the second map window in the first paragraph above.

Thanks a lot! I had been tinkering for a while on this.
The button is correctly firing up the window, but even setting the bar button to null is still showing a tiny cube in the bar
[attachment=0]vassal_toolbar.png[/attachment]

Is there a way around that??

Yes - put the bar button name inside of a Menu toolbar and blank the menu toolbar title

Will try that. Thanks!

Oh yeah forgot to mention that part :smiley: I often forget to do that myself until I see the little box and remember.