I'm using Autodesk Forge Viewer version 7.x and I have two questions regarding the context menu behavior.
Is it possible to modify or remove the default context menu items? By default, when right-clicking in the viewer, it shows built-in items such as:
Is there any supported way to rename or remove these default items?
Here is a simplified example of what I'm trying to achieve:
Javascript
viewer.registerContextMenuCallback('my-extension', (menu, status) => {
menu.push({
title: 'Custom Action',
target: () => { console.log('clicked'); },
// How to add submenu here?
});
});
Is there a supported way to define a submenu structure in Forge Viewer?
Environment:
Any insights or code examples would be greatly appreciated!
You can always check how certain things are done in the Viewer and just follow that. E.g. Section has a sub menu item:
So you can check how that item is added:
If you know which extension a given menu item belongs to then I guess you could just disable that extension.
https://aps.autodesk.com/blog/minimizing-viewer-workloads-loading-models-partially-selected-components-and-features-only
Otherwise you would have to somehow make sure that all extensions that are adding menu items are loaded before you call registerContextMenuCallback
so that you are called last then you have full control of all the other menu items