I’m a relatively new Vassal user and a very new would-be module extension designer/maintainer.
I’d like to create a custom class extension that adds a single toolbar button that appends some variable text to whatever is currently in the chat input box.
The module tutorial shows how to display text in the chat box, and that would be fine as a fall-back here, but it’d be better in this particular case if I could simply append it to the chat input.
Is this possible? If so, what classes/methods/events should I use to accomplish it?
Thanks for any help.
If you’re thinking of making a Java custom class, the one you’d want to extend is VASSAL.build.module.Chatter, which you can find in Chatter.java.
You could extend the main Chatter class with your own, and just override methods as appropriate – if I understand what you want to do correctly, you may be able to simply override e.g. the formatChat() method.
Also if you’re new to custom classes, there’s a template of a sample one on our wiki at github.com/vassalengine/vassal-module-template Conveniently the sample customclass is already a Chatter extension, so should be straightforward to convert (or as straightforward as custom classes ever are, ha ha).
Thanks Brian! Shortly after my post (and before it was let through), I ended up going to the repo and looking around until I found Chatter.getInputField. This property did the trick for my purposes.
Incidentally, I thought the source was pretty decently commented and easy to understand. Kudos to past and present maintainers!
Is this MyChatter custom class example still available? I cloned the vassal-module-template code as per the instructions at https://vassalengine.org/wiki/Custom_Classes_Intro but I can’t find the MyChatter.java there.
Whoops! The repo ended up with an accidental push to it from someone else that overwrote stuff.
We’ve restored it to what it’s supposed to be. I recommend you wipe that local directory completely (e.g. MyCustomClasses or whatever you called it) and re-clone it. Should show up then.
Let me know if any problems!
Brilliant, thanks Brian, it’s working now.