Removing context menu commands in the Forge Viewer

During last week’s Forge Accelerator, a developer wanted to strip the standard items from the context menu in his Forge Viewer application. We both searched for a while, until we found the answer: he’d been using this approach to add his own menu items – of course – but it turns out the exact same approach can be used to strip out unwanted items, too. The “context menu callback” receives a menu object that contains its various items: you can inspect them and remove the ones you don’t want, or even adopt a more brute-force approach as we’ve done below and remove everything.

Here’s the updated TypeScript extension from the original post with a few additional lines of code to clean the menu before we add our custom (still hugely theoretical, by the way) “Send to HoloLens” command.

/// <reference path=’../../../../../typings/lmv-client/lmv-client.d.ts’ />

 

export default class ContextMenuExtension extends Autodesk.Viewing.Extension {

  constructor(viewer:…

Read more

Leave a Comment