Leading and trailing spaces in text l abels

If I create a text label, using the mono-space font, and include leading and/or trailing spaces, such spaces are included in the label as displayed. This can be useful where you want a uniform appearance in the background of the label across multiple pieces with different text.

But when I clone the piece, the leading and trailing spaces are removed on the cloned copy. Is this deliberate? Or just an artifact of how things work?

I can even imagine a case where at a scenario setup I would want all spaces for the label, and the player(s) would edit during the game. Note that all space labels are not accepted during creation

Thanks

Well I’m sure it’s this code inside the Text Label that’s doing it:

public void mySetState(String s) { setLabel(s.trim()); }

Since “trim” removes leading and trailing spaces. I’m actually surprised your original piece’s label “survives” that (or maybe it too loses its spaces as soon as it’s saved and reloaded?)

If you want to work around it however you could put a $thing$ inside it that referenced a property that had leading/trailing spaces, and then the spaces would display?

I’m not precisely sure why the “trim” is there, and whether it is necessary – a more accomplished expert on our encoding/decoding would have to weigh in.

Brian

Yeah - the spaces don’t survive save/load, and trim probably has some generic usefulness, possibly w.r.t. buffer over-runs. I’ll find another way to achieve the effect I want.

If you don’t mind using HTML in your text labels, you could add   (the HTML entity for a non-breaking space) where you want spaces. Alternatively, if you set the text label to $someCalculatedProperty$, and then create a CP called someCalculatedProperty, you should be able to set that to " (put leading and trailing spaces inside double-quotes) ". Not positive that will work, but I can’t think why it wouldn’t.

It needs to be something a user can easily do when designing a scenario; html is too much. (Though I love it’s use in menu and chart labels.) The idea is that the pieces in a “wing” (or whatever) can be identified by the same color and size label, and the text of the label can further distinguish among the pieces

I have an alternate work-around

For similar applications I tend to use a image showing just a orange, say, rectangle of the required side. Then you place your text label at its center, with a transparent background. You can even use Game Piece Image Definitions inside Vassal to create such simple images, but beware of the limited colour palette. If the users are supposed to edit those text labels, I would make sure to truncate them to a maximum number of characters, to avoid them spewing out of the colored space.