Alter Button statement - MapBasic - 2023

MapInfo MapBasic Reference

Product type
Software
Portfolio
Locate
Product family
MapInfo
Product
MapInfo > MapBasic
Version
2023
Language
English
Product name
MapBasic
Title
MapInfo MapBasic Reference
First publish date
1985
Last updated
2023-09-12
Published on
2023-09-12T16:32:32.686312

Purpose

Enables, disables, selects, or deselects a button from a ButtonPad (toolbar) or a ribbon group.

Syntax

Alter Button { handler | ID button_id } 
	[ { Enable | Disable } ]
	[ { Check | Uncheck } ]

handler is the handler that is already assigned to an existing button. The handler can be the name of a MapBasic procedure, or a standard command code (e.g., M_TOOLS_RULER or M_WINDOW_LEGEND) from MENU.DEF.

button_id is a unique integer button identification number.

Description

If the Alter Button statement specifies a handler (e.g., a procedure name), MapInfo Pro modifies all buttons that call that handler. If the statement specifies a button_id number, MapInfo Pro modifies only the button that has that ID.

The Disable keyword changes the button to a grayed-out state, so that the user cannot select the button.

The Enable keyword enables a button that was previously disabled.

The Check and Uncheck keywords select and deselect ToggleButton type buttons, such as the Show Statistics Window button. The Check keyword has the effect of "pushing in" a ToggleButton control, and the Uncheck keyword has the effect of releasing the button. For example, the following statement selects the Show Statistics Window button:

Alter Button M_WINDOW_STATISTICS Check
Note: Checking or unchecking a standard MapInfo Pro button does not automatically invoke that button's action; thus, checking the Show/Hide Statistics button does not actually show the Statistics window-it only affects the appearance of the button. To invoke an action as if the user had checked or unchecked the button, issue the appropriate statement; in this example, the appropriate statement is the Open Window statement Statistics.

Similarly, you can use the Check keyword to change the appearance of a ToolButton. However, checking a ToolButton does not actually select that tool, it only changes the appearance of the button. To make a standard tool the active tool, issue a Run Menu Command statement, such as the following:

Run Menu Command M_TOOLS_RULER

To make a custom tool the active tool, use the syntax Run Menu Command ID IDnum.

Things to remember when using this command with the MapInfo Pro 64-bit:
  1. This command allows you to enable\disable or select\unselect a control added to ButtonPad group.
  2. If you check/uncheck using a mapinfo run menu command then controls which have an ischecked property bind are affected.

See Also:

Alter ButtonPad statement, Create ButtonPad statement, Run Menu Command statement