I have a random text button that has a hotkey shortcut. If I press the hotkey, it triggers just fine. I want to trigger this hotkey when doing a place marker in a game piece prototype. I added a trigger to the marker definition with the shortcut, but it doesn’t fire. What am I missing? Is it context? Do I need to make the hotkey a global hotkey or something?
You need to add the Global Hotkey trait to the piece.
@marktb1961 I’m still not getting it. Are you saying add a Global Hotkey to the marker? It seems like that is a way to have a command trigger another command. But what triggers the GHK? I added a trigger trait to the marker as well, but that still didn’t work.
The random text button is created at the root level of the module and has a hotkey of CTRL+SHIFT+H. I want it so that when I place a marker, it invokes the CTRL+SHIFT+H to display some random text.
I’ll come back with more when I get some time but meanwhile, maybe this section of the Ref Manual will help, if you haven’t seen it already.
A toolbar button is a component, not a piece. A key command you assign to a piece trait will try and execute on the piece itself, or be broadcast to other pieces if you use a Global Key Command. The reason adding a Trigger alone won’t suffice is that assigning Ctrl+Shift+H
just makes the piece ask itself to do something in response to that key combo–it’s not sending it elsewhere.
If you want a piece to send a command to a component (e.g. a toolbar button, a deck, some other non-piece VASSAL item), you have to employ the Global Hotkey piece trait. That’s the “bridge” between pieces and components.
I added a Global Hotkey piece trait and assume the Global Hotkey is “CTRL+SHIFT+H” but that doesn’t work. I also tried giving it a Key Command as well (and using a trigger to send the key command) but that didn’t work either. My bridge is broken!
Can you post a screenshot of your Global Hotkey config on the piece in question?
Without seeing everything you’ve done to this point, purely from the need as currently expressed I think you’d want:
In the area I’ve circled, you want whatever key command that the Place Marker trait is using (named command in the left box or keystroke command in the right box).
Then doing the Place Marker will simultaneously dispatch the Ctrl+Shift+H
to your toolbar button.
OK, so you have a Helicopter piece that places a Wreck marker. It looks like you’ve put the Global Hotkey into the Wreck marker, which I presume is the item getting put down by the Helicopter’s Place Marker trait. In that case, you need the Global Hotkey’s key command to be RandomWreck
instead of Ctrl+W
. The latter would work if the Global Hotkey trait was in the Helicopter piece and not the Wreck marker piece.
RandomWreck is the command to randomize the layer properties (there are 4 wreck graphics and that lets it pick a random one). Wasn’t sure how to fire multiple commands off of that.
You can do this multiple ways. If the placement of the Wreck marker is the thing that’s meant to make the toolbar button spit out some random text, in my opinion it might help your future self to put the Global Hotkey trait in the Helicopter piece, not the Wreck marker. You’d be doing two things simultaneously on Ctrl+W
–placing the Wreck marker, and executing the Global Hotkey to get your random text.
@JoelCFC25 Yep, that did it. I just copied the Global Hotkey to the Helicopter piece and it worked! Thanks for the tip.