moduleAddAction()
Adds a new action to a self-created menu in the Script Editor or module GEDI .
Synopsis
int moduleAddAction(string label, string icon, string shortcut, int menu, int
toolbar, string function);
Parameters
Parameter | Description |
---|---|
label | The label of the action. |
icon | The icon that is shown for the action in the menu. Has to be located in the pictures directory (the extensions png, .xpm, .bmp will be searched). |
shortcut | The shortcut that is used to select the action. "Ctrl", "Shift", "Alt" and "Meta" are recognized, for example, "Ctrl+Q". |
menu | The menu the action is added to (ID) or -1, which means it will not be added. |
toolbar | The toolbar the action is added to (ID) or -1, which means it
will not be added.
Note: If both values of menu and toolbar are -1, then the action
cannot be seen in a menu or a toolbar, but it can still be
executed via a shortcut.
|
function | The callback function that is executed when selecting the action. |
Return value
The ID of the action.
It is not allowed to launch the function moduleAddAction() in a panel.
Error
Missing or invalid arguments.
Description
Adds a new action to a self created menu in the Script Editor or GEDI module.
If the action shall be added to the GEDI, the script should be located in <project_directory>/scripts/gedi and must be called <name>_ext.ctl. When the GEDI is started, all scripts from this directory will be loaded.
If the action shall be added to the Script Editor, the script should be located in <project_directory>/scripts/scriptEditor and must be called <name>_ext.ctl. When the Script Editor is started, all scripts from this directory will be loaded.
The function moduleAddDockModule() isn't supported by the Script Editor menu.
Example
The following example adds the menu "MyTools" and the sub menu "MyTools2" to the GEDI module. The ID of the created menu "MyTools" is used when creating the sub menu "MyTools2". The return value of the moduleAddToolBar() function is used when adding an action using the moduleAddAction() function. Three different actions "Find in Files","action 2" and "action 3" will be added.
main()
{
int id = moduleAddMenu("MyTools");
int id2 = moduleAddSubMenu("MyTools2", id);
int tb = moduleAddToolBar("toolbar1");
DebugN(id, id2, tb);
int id3 = moduleAddAction("Find in Files", "", "Ctrl+I", id, -1,
"find");
int id4 = moduleAddAction("action 2", "undo", "", id, tb,
"action2");
int id5 = moduleAddAction("action 3", "redo", "", id2, tb,
"action3");
moduleAddDockModule("myDock", "projAdmin/console.pnl");
}
void find()
{
ModuleOnWithPanel("Find", -2, -2, 100, 200, 1, 1, "",
"grep.pnl", "", makeDynString());
}
void action2()
{
DebugN("action2", myModuleName());
}
void action3()
{
DebugN("action3", myModuleName());
}
Figure: Menu "MyTools", Submenu "MyTools2" and three different actions
Assignment
Miscellaneous functions
Availability
UI