Weird (inconsistent) action button behaviour

I have these action buttons set up, and they work fine. Click, lots of stuff happens, very convenient.

One day I noticed that I could add a Trigger Action with a menu command, which performed slightly different Keystrokes to the Trigger Action triggered by the Action Button, so a user could right-click the action button and select a menu command for a different result than a left-click.

Multi-function action buttons, awesome!

I made three such buttons, which are functionally identical, with the same traits in the same orders, with only a different Global Key Command trait and a different Report Action text in each button. All the rest is tied to the same Prototype, which is where the right-click Trigger Actions also are.

Here’s the weird bit:
Two of the buttons work “as intended”. You can left-click on them for a (non-menu) Trigger Action or right-click on them for different (menu) Trigger Actions.
One of the buttons works differently. If you right-click on it the non-menu Trigger Action triggers, then the right-click menu Trigger Actions appear, and clicking on them works as expected.

How is this possible? Which of the two results is a bug, and which is how the Vassal devs would expect things to happen?

Thanks for reading!

I expect how the first two buttons work to be the intended behavior. It sounds like something is getting crossed in the third button with its action button/trigger action command keys…

I think I have found the cause. This is going to sound crazy but I have tested it extensively:

When the right-click menu can be displayed entirely within the Vassal window, the right-click works as intended.
When the right-click menu is partially displayed outside the Vassal window (the menu is long, or the button is very close to the window edge), the left-click trigger triggers and then the right-click menu appears.

This can be tested with any button by expanding/shrinking the window, and the same button will behave differently depending on the above conditions.

Definitely a bug.

Thus spake Benkyo:

I think I have found the cause. This is going to sound crazy but I have
tested it extensively:

It’s not crazy. Java Swing draws context menus which fall entirely
within Swing windows itself, but relies on the window manager to draw
ones which fall at least partly outside of Swing windows.

I believe the explanation for what you’re seeing is that unfortunately
this causes the window focus to differ in these two cases. We don’t
control that, so it’s probably a bug in Java.

If you’d like me to investigate further, provide a test module.


J.

Here you go:
dropbox.com/s/di1j9vt50fyee … .vmod?dl=0

A 100x100 board, and two identical buttons with slightly different positions, a report triggered by the action button and 5 other reports triggered by right-click trigger menu options.