Reputation: 137
How to replace the context menu when an object is selected?
Currently I am trying this based on the API and the Autodesk.ADN.Viewing.Extension.ContextMenu.js example from Philippe Leefsma.
var contextMenu = new Autodesk.Viewing.UI.ObjectContextMenu(viewer);
contextMenu.buildMenu(Autodesk.Viewing.AGGREGATE_SELECTION_CHANGED_EVENT, [{ title: 'This is a menu item', target: function () { alert('Menu item clicked'); } }]);
viewer.setContextMenu(contextMenu);
Upvotes: 0
Views: 388
Reputation: 4375
It should be pretty straightforward to replace all menu items with your own ... Take a look there for a full sample
Autodesk.ADN.Viewing.Extension.AdnContextMenu.prototype.buildMenu =
function (event, status) {
//completely disable native menu
//var menu = Autodesk.Viewing.Extensions.ViewerObjectContextMenu.prototype.buildMenu.call(this, event, status);
//and sneak your own ...
var menu = []
menu.push({
title: "Dude menu item",
target: function () {
alert('Dude I was clicked!');
}
})
return menu;
};
Upvotes: 1