How to make Label visible/invisible on mouse click?


I made a HUD for each counter using Label. Is it possible to make the labels on the counters visible only when the counter is selected? That way, the board will not be cluttered with so many labels. Thanks.

From the Reference Manual:

  • Selected contains true when the piece has been selected with the mouse

Modify the Text Labels to include an Expression using the Selected property. In the following example, the text label will be blank unless the piece is selected. You will need to do this for each Text label.

I am not sure how this method will perform for a large number of labels / pieces. The Mouseover feature would give a similar result but not exactly what you’ve asked for.

Thanks, the code worked!
{Selected ? " " + Code + " " + Name + " PV " + PV + " " : “”}

1 Like

This looks interesting but I’m not getting it. Can you show me what the whole Text Lable configuration window looks like?

Here is sample for the Prototype to display various data above and below the counter. The “Selected ?” in the Text Label field hides all the Labels when the counter is NOT selected. When you click on the counter, the Label appears. This reduces the clutter on the board. I am trying to figure out how to do the same, but using command button or keyboard command, and not with a mouse click.

I’m thinking you could add a Dynamic Property to each piece with labels to toggle visible and invisible. Let’s say you named the property SeeLabels, you can do the label text similar to @marktb1961 suggestion above only for Selected you would substitute something like SeeLabels == yes. You could add a Menu Command with Named Key Command to set the property to the value of SeeLabels to “yes” for showing the labels and another Menu Command with Named Key Command to set the property to “no” for hiding the labels.

This way you could toggle the label visibility via right click for each piece and the label visibility would stay that way until changed by another right click choice.

For toggling via keyboard command, define Key Commands rather than Named Key Commands for setting the SeeLabel values to "yes’ or “no”. I think this will cause all the labels for all the counters with these Key Commands to go to the commanded state of visible or hidden.

You can name the Dynamic Property anything you want. I like to name mine so I can easily tell what its value represents and something different from properties already defined in Vassal like Selected. In addition to the property list @marktb1961 links to above there are other lists in the reference mostly showing the same properties, but some times not including a property mentioned elsewhere. (It’s hard to keep several lists of the same items current and identical.) Here are links to other lists of properties:

1 Like