Reputation: 54
I want to creat two level context menu but there is no api for this.Just look like this level context menu image what I can do?
Upvotes: 1
Views: 441
Reputation: 4375
It is rather straighforward to acheive a multi level context menu by deriving from Autodesk.Viewing.UI.ObjectContextMenu
. Simply provide an array in the target
field:
buildMenu (event, node) {
var menu = []
switch (node.type) {
case 'hubs':
menu.push({
title: 'Show details',
className: 'fa fa-share',
target: [{
title: 'Hub details',
className: 'fa fa-cloud',
target: () => {
this.emit('context.details', {
event, node, type: 'hubs'
})
}
}, {
title: 'Projects details',
className: 'fa fa-folder',
target: () => {
this.emit('context.details', {
event, node, type: 'hubs.projects'
})
}
}]
})
break
A complete example of this can be found here: DataContextMenu.js
Upvotes: 1
Reputation: 7070
Unfortunately, it's not available on current viewer version. You might have to write your own context menu in deep. But there is a workaround that you can follow:
Autodesk.Viewing.Private.ContextMenu
to provide multiple level menus.Autodesk.Viewing.UI.ObjectContextMenu
, then create your owned ObjectContextMenu
and replace contextMenu
property with the your owned multiple levels ContextMenu
from the step 1.Autodesk.Viewing.Extensions.ViewerObjectContextMenu
, then write your owned ViewerObjectContextMenu
that inherits the custom ObjectContextMenu
from the step 2.P.S. This is just a workaround, it's not the formal solution, you might have to use it at your own risk.
Upvotes: 0