DIAdem Help

Content Type
Programming Language
Current manual

Event: OnShowingContextMenu

Event: OnShowingContextMenu

Is triggered when a context menu displays in an area in DIAdem VIEW.

The event starts the user command you assigned to the OnShowingContextMenu property. If the script of the user command contains an error, DIAdem aborts the script without an error message. The DIAdem logfile contains information on the error.

The user command receives two parameters: The first parameter corresponds to an Area object and contains the current area when the user command opens. The second parameter corresponds with a MenuPoints object and receives a collection of the context menu entries.

If you open a context menu in DIAdem VIEW, DIAdem configures this context menu and then triggers the event OnShowingContextMenu before the context menu displays. If you select a context menu item, DIAdem triggers the event OnContextMenuPointSelected. Then DIAdem closes the context menu.

Refer to Working with Events in DIAdem for further information on events in DIAdem. 

Object.OnShowingContextMenu
ObjectEvents
Object with this event
Object.OnShowingContextMenuString with read and write access
Note  To test the example script, you must first save the script and register it as a user command in the dialog box that opens when you select Settings»Extensions»User Commands.

The following example executes the user command MyOnShowingContextMenu as soon as you open the context menu in DIAdem VIEW. The user command deletes the existing items in the context menu and adds two new items. When you select a context menu item, the example executes the MyOnContextMenuPointSelected user command, which displays the selected item in a message:

Call AddUserCommandToEvent("View.Events.OnShowingContextMenu","MyOnShowingContextMenu")
Call AddUserCommandToEvent("View.Events.OnContextMenuPointSelected","MyOnContextMenuPointSelected")

Sub MyOnShowingContextMenu(oArea, oMenuPoints)
  Call oMenuPoints.RemoveAll
  Call oMenuPoints.Add("MyMenuPoint1", 1)
  Call oMenuPoints.Add("MyMenuPoint2", 2)
End Sub

Sub MyOnContextMenuPointSelected(oArea, oMenuPoint)
  Select Case oMenuPoint.ID
    Case 1    Call MsgBoxDisp("MyMenuPoint1 selected")
    Case 2    Call MsgBoxDisp("MyMenuPoint2 selected")
  End Select
End Sub

Note Use the AddUserCommandToEvent command to assign several user commands to one event. Use the RemoveUserCommandFromEvent command to delete a single user command from a list of user commands which you assigned to an event. Assign an empty string to an event so that the event is no longer assigned to a user command.

In This Section
Was this information helpful?