@vnkdj5 wrote:
if (diagram instanceof go.Palette)
return;Example:
indent preformatted text by 4 spaces
function showContextMenu(obj, diagram, tool) {
// Show only the relevant buttons given the current state.
var cmd = diagram.commandHandler;
/*
document.getElementById(“cut”).style.display = cmd.canCutSelection() ? “block” : “none”;
document.getElementById(“copy”).style.display = cmd.canCopySelection() ? “block” : “none”;
document.getElementById(“paste”).style.display = cmd.canPasteSelection() ? “block” : “none”;
*/
document.getElementById(“delete”).style.display = (obj !== null && cmd.canDeleteSelection()) ? “block” : “none”;
document.getElementById(“componentConfig”).style.display = (obj !== null ? “block” : “none”);
//more such componentsif (obj instanceof go.Node) { //Setting selected component for further processing $scope.selectedComponent.category = obj.data.category; $scope.selectedComponent.key = obj.data.key; } if (diagram instanceof go.Palette) //don't show context menu for palette elements return; // Now show the ,whole context menu element cxElement.style.display = "block"; // we don't bother overriding positionContextMenu, we just do it here: var mousePt = diagram.lastInput.viewPoint; cxElement.style.left = mousePt.x + "px"; cxElement.style.top = mousePt.y + "px"; }
Posts: 2
Participants: 2