MCPcopy Index your code
hub / github.com/csev/py4e / onMouseDown

Function onMouseDown

tools/pythonauto/static/codemirror/codemirror.js:1722–1865  ·  view source on GitHub ↗
(e)

Source from the content-addressed store, hash-verified

1720
1721 var lastClick, lastDoubleClick;
1722 function onMouseDown(e) {
1723 if (signalDOMEvent(this, e)) return;
1724 var cm = this, display = cm.display, doc = cm.doc, sel = doc.sel;
1725 sel.shift = e.shiftKey;
1726
1727 if (eventInWidget(display, e)) {
1728 if (!webkit) {
1729 display.scroller.draggable = false;
1730 setTimeout(function(){display.scroller.draggable = true;}, 100);
1731 }
1732 return;
1733 }
1734 if (clickInGutter(cm, e)) return;
1735 var start = posFromMouse(cm, e);
1736 window.focus();
1737
1738 switch (e_button(e)) {
1739 case 3:
1740 if (captureMiddleClick) onContextMenu.call(cm, cm, e);
1741 return;
1742 case 2:
1743 if (webkit) cm.state.lastMiddleDown = +new Date;
1744 if (start) extendSelection(cm.doc, start);
1745 setTimeout(bind(focusInput, cm), 20);
1746 e_preventDefault(e);
1747 return;
1748 }
1749 // For button 1, if it was clicked inside the editor
1750 // (posFromMouse returning non-null), we have to adjust the
1751 // selection.
1752 if (!start) {if (e_target(e) == display.scroller) e_preventDefault(e); return;}
1753
1754 setTimeout(bind(ensureFocus, cm), 0);
1755
1756 var now = +new Date, type = "single";
1757 if (lastDoubleClick && lastDoubleClick.time > now - 400 && posEq(lastDoubleClick.pos, start)) {
1758 type = "triple";
1759 e_preventDefault(e);
1760 setTimeout(bind(focusInput, cm), 20);
1761 selectLine(cm, start.line);
1762 } else if (lastClick && lastClick.time > now - 400 && posEq(lastClick.pos, start)) {
1763 type = "double";
1764 lastDoubleClick = {time: now, pos: start};
1765 e_preventDefault(e);
1766 var word = findWordAt(getLine(doc, start.line).text, start);
1767 extendSelection(cm.doc, word.from, word.to);
1768 } else { lastClick = {time: now, pos: start}; }
1769
1770 var last = start;
1771 if (cm.options.dragDrop && dragAndDrop && !isReadOnly(cm) && !posEq(sel.from, sel.to) &&
1772 !posLess(start, sel.from) && !posLess(sel.to, start) && type == "single") {
1773 var dragEnd = operation(cm, function(e2) {
1774 if (webkit) display.scroller.draggable = false;
1775 cm.state.draggingText = false;
1776 off(document, "mouseup", dragEnd);
1777 off(display.scroller, "drop", dragEnd);
1778 if (Math.abs(e.clientX - e2.clientX) + Math.abs(e.clientY - e2.clientY) < 10) {
1779 e_preventDefault(e2);

Callers

nothing calls this directly

Calls 15

onFunction · 0.85
getRectFunction · 0.85
signalDOMEventFunction · 0.70
eventInWidgetFunction · 0.70
clickInGutterFunction · 0.70
posFromMouseFunction · 0.70
e_buttonFunction · 0.70
extendSelectionFunction · 0.70
bindFunction · 0.70
e_preventDefaultFunction · 0.70
e_targetFunction · 0.70
posEqFunction · 0.70

Tested by

no test coverage detected