-
Notifications
You must be signed in to change notification settings - Fork 23
Open
Description
Thanks for your help earlier!
we need to open context menu of edges by left click event , and we would like to have an option evtType to customise cxttap event
cytoscape.js-edge-editing/src/UIUtilities.js
Lines 1286 to 1367 in 149c0aa
cy.on('cxttap', eCxtTap = function (event) { | |
var target = event.target || event.cyTarget; | |
var targetIsEdge = false; | |
try{ | |
targetIsEdge = target.isEdge(); | |
} | |
catch(err){ | |
// this is here just to suppress the error | |
} | |
var edge, type; | |
if(targetIsEdge){ | |
edge = target; | |
type = anchorPointUtilities.getEdgeType(edge); | |
} | |
else{ | |
edge = anchorManager.edge; | |
type = anchorManager.edgeType; | |
} | |
var menus = cy.contextMenus('get'); // get context menus instance | |
if(!edgeToHighlight || edgeToHighlight.id() != edge.id() || anchorPointUtilities.isIgnoredEdge(edge) || | |
edgeToHighlight !== edge) { | |
menus.hideMenuItem(removeBendPointCxtMenuId); | |
menus.hideMenuItem(addBendPointCxtMenuId); | |
menus.hideMenuItem(removeControlPointCxtMenuId); | |
menus.hideMenuItem(addControlPointCxtMenuId); | |
return; | |
} | |
var cyPos = event.position || event.cyPosition; | |
var selectedIndex = getContainingShapeIndex(cyPos.x, cyPos.y, edge); | |
// not clicked on an anchor | |
if (selectedIndex == -1) { | |
menus.hideMenuItem(removeBendPointCxtMenuId); | |
menus.hideMenuItem(removeControlPointCxtMenuId); | |
if(type === 'control' && targetIsEdge){ | |
menus.showMenuItem(addControlPointCxtMenuId); | |
menus.hideMenuItem(addBendPointCxtMenuId); | |
} | |
else if(type === 'bend' && targetIsEdge){ | |
menus.showMenuItem(addBendPointCxtMenuId); | |
menus.hideMenuItem(addControlPointCxtMenuId); | |
} | |
else if (targetIsEdge){ | |
menus.showMenuItem(addBendPointCxtMenuId); | |
menus.showMenuItem(addControlPointCxtMenuId); | |
} | |
else { | |
menus.hideMenuItem(addBendPointCxtMenuId); | |
menus.hideMenuItem(addControlPointCxtMenuId); | |
} | |
anchorPointUtilities.currentCtxPos = cyPos; | |
} | |
// clicked on an anchor | |
else { | |
menus.hideMenuItem(addBendPointCxtMenuId); | |
menus.hideMenuItem(addControlPointCxtMenuId); | |
if(type === 'control'){ | |
menus.showMenuItem(removeControlPointCxtMenuId); | |
menus.hideMenuItem(removeBendPointCxtMenuId); | |
if (opts.enableMultipleAnchorRemovalOption && | |
edge.hasClass('edgecontrolediting-hasmultiplecontrolpoints')) { | |
menus.showMenuItem(removeAllControlPointCtxMenuId); | |
} | |
} | |
else if(type === 'bend'){ | |
menus.showMenuItem(removeBendPointCxtMenuId); | |
menus.hideMenuItem(removeControlPointCxtMenuId); | |
} | |
else{ | |
menus.hideMenuItem(removeBendPointCxtMenuId); | |
menus.hideMenuItem(removeControlPointCxtMenuId); | |
menus.hideMenuItem(removeAllControlPointCtxMenuId); | |
} | |
anchorPointUtilities.currentAnchorIndex = selectedIndex; | |
} | |
anchorPointUtilities.currentCtxEdge = edge; | |
}); |
yasstec
Metadata
Metadata
Assignees
Labels
No labels