moduleSetAction()

Changes a selected attributes state of a menu or sub-menu entry that was added using moduleAddAction().

Synopsis

int moduleSetAction(int id, string attribute, anytype value);

Parameters

Parameter Description
id Id (return value) of the action that was added using moduleAddAction().
attribute

Following attributes are available:

  • enabled => Is used to set the menu entry enabled or disabled

  • visible => Is used to set the menu entry (in)visible

  • separator => Is used to set/remove a separator

  • text => Is used to set the text of the menu entry dynamically

  • checkable => Is used to set a menu entry checkable

  • checked => Is used to set a menu entry checked

  • icon => A filename (relative to the pictures directory) is given to use as icon.

value Value for the selected attribute

Return value

Error

Missing or invalid arguments.

Description

Changes a selected attributes state of a menu entry that was added using moduleAddAction().

The Id for sub-menu entries is the return value of moduleAddSubMenu().

Example

Adds the menu "MyTools" and the sub menu "MyTools2" to the Gedi or VISION module. Note that 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" are 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");
  int id6 = 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

An action can be disabled or set invisible as follows (disables the action with the id "id4"):

main()
{
  int m = moduleSetAction(id4, "enabled", false);
}

Assignment

Miscellaneous functions

Availability

UI