Disabling Toolbar Buttons using “disable-on-global-property”

Vassal v3.6 introduced a new feature that allows most types of Toolbar Button to be disabled by setting a Global Property true (and conversely, re-enabled if the Global Property is set non-true. As shown in this example of a map-level Global Key Command:

When the Global Property gNextDisabled is set true, the image of the button appears greyed-out as shown here and does not respond. An alternative image can be specified if required.
image

The rest of this article shares some experience using this feature that I obtained whilst developing the Liberté module.

Map Buttons
The map configuration panel does not offer the “disable-on-global-property” feature. However, you can achieve the same effect by encapsulating each map button in a Toolbar Menu. This example controls a Player Hand window called “Blue”;

Conditional Buttons
The feature allows multiple buttons to be controlled from a single Action Button or hotkey without interfering with each other. For example, in a game with multiple Game Piece inventory Windows, a single Action Button can be used to activate the required inventory depending on the game state. In this case the Action Button provides the user interface (button image, hotkey) and the GPIWs have an internal hotkey and are enabled or disabled, each by a unique Global Property. Example below shows two GPIWs controlled by a single Action Button; the Global Properties gSpecialEnd & gCRtallyOff are set such that the controlling Action Button will only display one of the GPIWs (or none).

Control
The button control feature relies on the module designer to set each button’s Global Property at appropriate points in the game flow. Consider using the Change-Property feature (with Hotkeys) rather than the Set Global Property trait, as this might be easier to maintain. Also, because button control works through a fixed value (true or non-true) you may find that you need to create Global Properties in pairs, where one is always the opposite of the other.

1 Like

Nice Intro to the feature.

However, I’m confused by your statement near the end “…you may find that you need to create Global Properties in pairs…”

Since the button disable is based on the value of a single Global Property with two states, I suspect you were intending to say you need to create “Set Global Property” in pairs…

1 Like

I did mean pairs but really this is just a specific case of an approach whereby the module designer controls multiple related buttons through a set of Global Properties.

e.g. for a pair of buttons that are mutually exclusive, the Global Properties might be

buttonA_Disabled
buttonB_Disabled

In the module when buttonA is set True, buttonB must be set False and vice-versa.

To expand on this; I found it helpful to use Change-Property entries on the Global Properties rather than the Set Property trait. That way, the actions that change the button state are kept in one place and one hotkey can set (or clear) both buttons.

1 Like

Correction - for “Toolbar Menu”, read “Multi-Action Button”.