Skip to main content

Adding a Single Context Menu Entry

To include one context menu entry, the override method should return a ContextMenuEntry object. The properties for a valid ContextMenuEntry are:
nameThe text that appears in the menu
iconAn icon ligature name that appears next to the name
callbackThe function that is triggered when a user clicks or presses the entry
Follow these steps to add a single context menu entry:
Run the following:
// SampleContextMenuEntryLayer.ts
import {
ContextMenuEntryInterface, CustomLayer,
MouseEventCoordinatesInterface
} from "@navvis/ivion";

export class SampleContextMenuEntryLayer extends CustomLayer
{
public onContextMenu(pos: MouseEventCoordinatesInterface): ContextMenuEntryInterface
{
//return the ContextMenuEntryInterface
return {
name: "Go to Navvis",
icon: "fa-globe",
callback: () =>
{
window.open("https://www.navvis.com")
}
}
}
}