Search code examples
eventsautodesk-forgeautodesk-viewerautodeskforge

How can I disable the right click event or how can I hide the context menu on the Autodesk Forge Viewer


How can ı disable right click event on autodesk forge viewer. I want to hide the context menu.Does anyone have an idea about this?


Solution

  • if you just want to disable context menu, just set null to setContextMenu method.

    viewer.setContextMenu(null);
    

    if you would like to show context menu again, you just preserve context and set it.

    // you need to get current context menu before calling setsetContextMenu(null)
    var contextMenu = viewer.contextmenu;  
    viewer.setContextMenu(null);
    
    
    ....
    
    //set preserved contextMenu inf you want to show it again.
    viewer.setContextMenu(contextMenu);