MCPcopy Create free account
hub / github.com/TruthHun/BookStack / leftButtonDown

Function leftButtonDown

static/mergely/lib/codemirror.js:3607–3630  ·  view source on GitHub ↗
(cm, e, start)

Source from the content-addressed store, hash-verified

3605
3606 var lastClick, lastDoubleClick;
3607 function leftButtonDown(cm, e, start) {
3608 if (ie) setTimeout(bind(ensureFocus, cm), 0);
3609 else cm.curOp.focus = activeElt();
3610
3611 var now = +new Date, type;
3612 if (lastDoubleClick && lastDoubleClick.time > now - 400 && cmp(lastDoubleClick.pos, start) == 0) {
3613 type = "triple";
3614 } else if (lastClick && lastClick.time > now - 400 && cmp(lastClick.pos, start) == 0) {
3615 type = "double";
3616 lastDoubleClick = {time: now, pos: start};
3617 } else {
3618 type = "single";
3619 lastClick = {time: now, pos: start};
3620 }
3621
3622 var sel = cm.doc.sel, modifier = mac ? e.metaKey : e.ctrlKey, contained;
3623 if (cm.options.dragDrop && dragAndDrop && !cm.isReadOnly() &&
3624 type == "single" && (contained = sel.contains(start)) > -1 &&
3625 (cmp((contained = sel.ranges[contained]).from(), start) < 0 || start.xRel > 0) &&
3626 (cmp(contained.to(), start) > 0 || start.xRel < 0))
3627 leftButtonStartDrag(cm, e, start, modifier);
3628 else
3629 leftButtonSelect(cm, e, start, type, modifier);
3630 }
3631
3632 // Start a text drag. When it ends, see if any dragging actually
3633 // happen, and treat as a click if it didn't.

Callers 1

onMouseDownFunction · 0.70

Calls 5

bindFunction · 0.70
activeEltFunction · 0.70
leftButtonStartDragFunction · 0.70
leftButtonSelectFunction · 0.70
cmpFunction · 0.50

Tested by

no test coverage detected