0

选择对象时如何替换上下文菜单?

目前我正在尝试基于 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);    
4

1 回答 1

1

用您自己的菜单项替换所有菜单项应该非常简单......看看那里的完整示例

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;
      };
于 2016-10-18T12:43:09.597 回答