in modules/behavior/draw.js [123:165]
function click() {
var d = datum();
var target = d && d.properties && d.properties.entity;
var mode = context.mode();
var targetGeometry = target && target.geometry(context.graph());
if (target && target.type === 'node') { // Snap to a node
if (targetGeometry !== 'vertex' && !context.presets().allowsVertex(target, context.graph())) return;
if (mode.id === 'add-point') {
if (!schemaManager.canSnapNodeWithTagsToNode(mode.defaultTags, target, context.graph())) return;
}
dispatch.call('clickNode', this, target, d);
} else if (target && target.type === 'way') { // Snap to a way
if (mode.id === 'add-point') {
if (!mode.preset.matchGeometry('vertex')) return;
if (!schemaManager.canAddNodeWithTagsToWay(mode.defaultTags, target, context.graph())) return;
}
var choice = geoChooseEdge(
context.childNodes(target), context.mouse(), context.projection, context.activeID()
);
if (!choice) return;
var edge = [target.nodes[choice.index - 1], target.nodes[choice.index]];
dispatch.call('clickWay', this, choice.loc, edge, d);
} else {
if (mode.id === 'add-point' && !mode.preset.matchGeometry('point')) return;
dispatch.call('click', this, context.map().mouseCoordinates(), d);
}
}