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 stereotype
  
Creating a context menu command through a stereotype
Typically, you will want to create Stereotypes within a profile Package.
This topic documents creating a Stereotype through the Packages pane. For information about using a Profile Diagram to create a Stereotype, specify valid model item types and define Scripts, see Overview of Profile Diagrams.
To create a context menu command through a stereotype:
1. Right-click the profile Package, point to New , point to UML, point to Profiles, and then click Stereotype.
2. Type a name for the Stereotype, and then press the Enter key.
If you want the display name of the Stereotype in Modeler to be different from its real name: on the General tab of the Stereotype's property pages, type the display name in the Name Alias box.
3. Open the Stereotype's Property Pages, and select valid model items types for the Stereotype (the Stereotype can be applied only to items whose type is valid):
a. Click the Items tab.
b. In the drop-down list box select Model Item Types, and then click the Link button.
c. In the middle or right pane, select the check boxes associated with valid model item types.
d. In the middle or right pane, clear the check boxes associated with invalid model item types.
e. Click OK.
4. Click the Menu tab, and then click the New Item button.
5. Ensure that the new entry is selected, and then click the selected cell in the Context Menu Text column.
6. Type the command name that you want to appear on the context menu, and then press the Enter key.
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.
7. Set the Status Bar Text property to the text you want displayed in the Modeler status bar when the command is highlighted.
8. If you are creating a context menu command for an item, rather than a diagram, set the Command Context property as required:
a. Ensure that the entry is selected, and then click the selected cell in the Command Context column.
b. Set the Context property to DictItem, SymbolOnly or Universal:
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.
9. If the Command Context is set to SymbolOnly or Universal, you can select the diagram types for which the context menu command appears:
a. Ensure that the entry is selected, and then click the selected cell in the Applicable Diagram Type column.
b. From the Links Editor, select the check boxes associated with the diagram types on which you want the context menu command to be shown.
Note that if no check boxes are selected, the context menu command is available on all diagram types.
c. Click OK.
10. If you want a separator before the command you are creating:
a. Ensure that the entry is selected, and then click the selected cell in the Separator Before column.
b. Set the Separator Before property to Yes.
11. Ensure that the new entry is selected, and then click the Edit Script button.
12. In the window that opens, type the script for the context menu command.
Write the script within the RunMenuUI, CommitMenu and AfterMenuCommit functions. For more information about working with scripts, see Creating a Context Menu Command Through a Script.
The context menu command you created will appear on the context menu of any item or diagram that is stereotyped directly by the Stereotype.
* 
The 'Apply to All Objects of Associated Model Item Types' option will not apply a Stereotype's context menu commands to any items.