如何在选择对象时替换上下文菜单?
目前我正在尝试基于API和Philippe Leefsma的Autodesk.ADN.Viewing.Extension.ContextMenu.js示例。
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);
答案 0 :(得分:1)
用您自己的菜单项替换所有菜单项应该非常简单...看看there获取完整的样本
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;
};