version 1
CT ON MENU (area; method)
| Parameter | Type | Description | |
| area | Longint | 4D Chart area | |
| method | String | Name of the method to call |
Description
The CT ON MENU command executes method each time a menu command is activated in either the User or Custom Menus environments. The menu command can also be called by using the CT DO COMMAND command, as long as the menu command is called in method.
The called method returns three parameters:
| Parameter | Description |
| $1 | A Long integer containing the ID for the 4D Chart area. |
| $2 | A Long integer containing the menu item number. |
| $3 | A Long integer containing the number of the modifier key pressed. |
The $3 parameter corresponds to one of the following modifier keys (or combination of modifier keys):
| Value | Modifier Key |
| 0 | No modifier |
| 1 | Ctrl (Windows) or Command (Macintosh) key |
| 2 | Shift key |
| 4 | Alt (Windows) or Option (Macintosh) key |
| 8 | Control key (Macintosh) |
If a combination of modifier keys is pressed, the values are added together and passed as a parameter. For example, a value of 10 indicates that the user held down the Shift and Control keys while choosing a menu item.
If you plan to compile your database, you should declare the types of these parameters, as follows:
C_LONGINT ($1;$2;$3)
Example
This example launches the MenuProc event method.
CT ON MENU (Area;"MenuProc")
The MenuProc method controls the user's access to menu commands. If either the Save as Template or Properties menu command is selected, the user is presented with an alert and the menu selection is ignored. All other menu items are executed without interruption.
Following is the code for the MenuProc method.
C_LONGINT ($1;$2;$3)
Case of
: ($2=1006) `Save as Template
ALERT("You cannot save templates.")
: ($2=2011) `Properties
ALERT("You do not have access to Properties.")
Else
CT DO COMMAND (vArea;$2)
End case
See Also