This event is generated when the macro menu is rebuilt.

syntaxSyntax:
function OnMenu()

Remarks

This event is generated when the macro menu is rebuilt. The purpose of this function is to get the menu items related to the macro commands.

Use the DlxApp.GetMenu method to get the main macros menu of the ribbon in which you want to insert commands.

Example

  Copy codeCopy code
function OnMenu()
{
  var menu = DlxApp.GetMenu(DlxApp.MENU_DWG);
  if (menu.IsValid())
  {
    var subMenu = menu.AddMenu("My Macro");
    subMenu.AddCommand("command10", 10, "Description of command 10\nCmd10");
    subMenu.AddCommand("command20", 20, "Description of command 20\nCmd20");
    subMenu.AddLabel("Label");
    subMenu.AddCommand("command30", 30, "Description of command 30\nCmd30");
    subMenu.AddCommand("command40", 40, "Description of command 40\nCmd40");
    subMenu.AddSeparator();
    subMenu.AddCommand("command50", 50, "Description of command 50\nCmd50");
    subMenu.AddCommand("command60", 60, "Description of command 60\nCmd60");
  }
}

function OnMenuUpdateCommand(cmd)
{
  switch (cmd.GetCommandId())
  {
  case 10:
    cmd.Enable(true);
    break;
  case 20:
    cmd.Enable(true);
    break;
  case 30:
    cmd.Enable(true);
    break;
  case 40:
    cmd.Enable(true);
    cmd.SetCheck(true);
    break;
  case 50:
   cmd.Enable(false);
    break;
  case 60:
    cmd.Enable(true);
    break;
  }
}

function OnMenuCommand(cmdId)
{
  switch (cmdId)
  {
    case 10:
      DlxApp.Printf("CmdId 10");
      break;
    case 20:
      DlxApp.Printf("CmdId 20");
      break;
    case 30:
      DlxApp.Printf("CmdId 30");
      break;
    case 40:
      DlxApp.Printf("CmdId 40");
      break;
    case 50:
      DlxApp.Printf("CmdId 50");
      break;
    case 60:
      DlxApp.Printf("CmdId 60");
      break;
  }
}

See also