Method: RemoveAll for MenuPoints
- Updated2024-09-12
- 2 minute(s) read
Context Menu Object > Methods > Method: RemoveAll for MenuPoints
Method: RemoveAll for MenuPoints
Removes all items from the context menu.
Object.RemoveAll
| Object | MenuPoints Object with this method |
| Note To test the following example script, you must first save the script and register the script as a user command in the dialog box that opens when you select Settings»Extensions»User Commands. |
The following example deletes all the items from the context menu. The example adds three new items to the context menu and then deletes the item MyMenuPoint3. If you click a context menu item, a message displays:
'--- For DIAdem-NAVIGATOR ------------------------------------------ Call AddUserCommandToEvent("Navigator.Events.OnShowingContextMenu", "MyNavigatorOnShowingContextMenu") Call AddUserCommandToEvent("Navigator.Events.OnContextMenuPointSelected","MyNavigatorOnContextMenuPointSelected") Sub MyNavigatorOnShowingContextMenu(ParentObj, MenuPoints) Call MenuPoints.RemoveAll Call MenuPoints.Add("MyMenuPoint1", 1) Call MenuPoints.Add("MyMenuPoint2", 2) Call MenuPoints.Add("MyMenuPoint3", 3) Call MenuPoints.Remove(3) End Sub Sub MyNavigatorOnContextMenuPointSelected(ParentObj, MenuPoint) Select Case MenuPoint.ID Case 1 Call MsgBoxDisp("DIAdem-NAVIGATOR: MyMenuPoint1 selected") Case 2 Call MsgBoxDisp("DIAdem-NAVIGATOR: MyMenuPoint2 selected") End Select End Sub '--- For DIAdem-VIEW ------------------------------------------ Call AddUserCommandToEvent("View.Events.OnShowingContextMenu", "MyViewOnShowingContextMenu") Call AddUserCommandToEvent("View.Events.OnContextMenuPointSelected","MyViewOnContextMenuPointSelected") Sub MyViewOnShowingContextMenu(Area, MenuPoints) Call MenuPoints.RemoveAll Call MenuPoints.Add("MyMenuPoint1", 1) Call MenuPoints.Add("MyMenuPoint2", 2) Call MenuPoints.Add("MyMenuPoint3", 3) Call MenuPoints.Remove(3) End Sub Sub MyViewOnContextMenuPointSelected(Area, MenuPoint) Select Case MenuPoint.ID Case 1 Call MsgBoxDisp("DIAdem-VIEW: MyMenuPoint1 selected") Case 2 Call MsgBoxDisp("DIAdem-VIEW: MyMenuPoint2 selected") End Select End Sub