Customization > Extensibility Through Profiles, Stereotypes, Tag Definitions and Scripts > Advanced extensibility through stereotype scripts and script items > Extending context menu commands through stereotypes and scripts > Creating a context menu command through a script
  
Creating a context menu command through a script
Typically, you will want to create Scripts within a profile Package.
To create a context menu command through a script:
1. Right-click the profile Package, point to New, point to UML, point to Profiles, and then click Script.
2. Type a name for the Script, and then press the Enter key.
3. Open the Script's Property Pages, and then click the Settings tab.
4. In the Script Type list, select MenuCommand
5. In the Menu Text box, type the text that you want to appear on the context menu.
To create a submenu, include a backslash. For example, My Submenu\My Command.
To create a shortcut letter for the command, prefix the letter with an ampersand. For example, &My Command.
To use an ampersand in the command name, prefix the ampersand with an ampersand. For example, Delete && Propagate.
6. In the Status Bar Text box, type the text you want displayed in the Modeler status bar when the command is highlighted.
7. If you are creating a context menu command for an item, rather than a diagram, set the Context property as required:
DictItem - menu command appears when the item is right-clicked in a pane or the Property Pages only.
SymbolOnly - menu command appears when the item is right-clicked on a diagram only.
Universal - menu command appears when the item is right-clicked anywhere in Modeler.
8. If you want a separator to appear before the command you are creating, select the Separator Before check box.
9. Click the Items tab, in the Show Associated list select Model Item Types, click the Link button, select the valid model item types, and then click OK.
10. If the Context is set to SymbolOnly or Universal, you can select the diagram types for which the context menu command appears: Click the Items tab, in the Show Associated list select Applicable Diagram Types, click the Link button, select the valid diagram types, and then click OK.
Note that if no diagram types are selected, the context menu command can appear on all diagram types. If one or more diagram types are selected, the context menu command can appear only on those diagram types.
11. Click the Script tab.
12. In the box, type the script for the context menu command.
If you want to change the text in a larger window with the Text Format Toolbar available, click the Editor button.
Write the script within the RunMenuUI, CommitMenu and AfterMenuCommit functions.
For more information about working with scripts, see:
Script Functions, Attributes and Objects — Menu Command Scripts
Script Functions, Attributes and Objects — Overview
Script Template for Menu Command Scripts
If you want to group the menu command with other Script applied menu commands and specify which order those commands appear, see Ordering script applied commands on a customized menu.
The context menu command you created will appear on the context menu of items and diagrams that have a valid type.