You can add a
context menu at the application level or you can have a context menu just for
certain types of entities. The application level context menu displays when
the user clicks on the drawing background. You add this context menu using AddDefaultContextMenuExtension of the
Application. In this example a context menu is being created. The class for a
context menu is the
ContextMenuExtension and it has properties such as the Title. The
ContextMenuExtension also has a collection of MenuItems. Here a menu item
named M I is created and the constructor for it takes a string which will be
the text the user sees on the menu item. When the user right clicks on the drawing
background the context menu will display and there will be a new item on the
menu with the text “circle Jig”. When they click on the menu, the menu items
will display. In this case the menu item will have the text “Run Circle Jig”.
When they click on the menu item, the function CallBackOnClick will be
called. You can see that AddHander is used to control which function will be
used. You can also create a context menu that will display when the user
right clicks on a particular type of object. To create this type of context
menu, you use AddObjectContextMenuExtension. Notice that one of the arguments
for this method takes an RXClass. In this example the context menu will
display when the user right clicks on any line in the drawing. In the lab we will only be adding an
application level context menu. However it would be easy to change it so it
uses the entity example here instead. |
|