menu_add_option() adds commands to a menu. These command will be used to trigger actions at runtime.
Syntax
menu_add_option(menu_id,"label", action_id [, enabled] [,"tooltip"] [,"image"])
Parameters
menu_id |
identifier of the menu to which a new command is added (INTEGER) |
label |
|
action_id |
identifier of the new (=added) menu command (INTEGER) - must be unique for the program |
enabled |
(optional) specifies whether the menu command must be visible or not (INTEGER: 1 or 0) |
tooltip |
(optional) specifies the text to be displayed as a tooltip to the menu command (VARCHAR or quoted STRING) |
image |
(optional) specifies the path to the image which will be displayed to the menu command |
Usage and examples
Here is the example of the menu_add_option() full syntax:
CALL menu_add_option(submenu_id, "1st command", 1, 1,"This is the 1st command in this menu", "qx://application/ok2.png")
Here is the example of the menu_add_option() basic syntax (no optional parameters are specified):
CALL menu_add_option(submenu_id, "1st command", 1)
If the fourth parameter (= enabled) is set to 0, the menu command will be hidden at runtime:
CALL menu_add_option(submenu_id, "1st command", 1, 0)
menu_add_option() can be used to add separators between menu commands in top menus:
CALL menu_add_option(submenu_id, "-", 2)
In tree menus, you'll get a wider space between two menu commands:
To omit the tooltip at runtime, you have to pass an empty string as the fifth parameter:
CALL menu_add_option(submenu_id, "1st command", 1, 1, "", "qx://application/ok2.png")
CALL menu_add_option(submenu_id, "1st command", 1, 1, "qx://application/ok2.png")