MCPcopy
hub / github.com/csev/py4e / onMouseDown

Function onMouseDown

tools/pythonauto/static/codemirrorepl/codemirrorepl.js:553–650  ·  view source on GitHub ↗
(e)

Source from the content-addressed store, hash-verified

551 }
552
553 function onMouseDown(e) {
554 setShift(e_prop(e, "shiftKey"));
555 // Check whether this is a click in a widget
556 for (var n = e_target(e); n != wrapper; n = n.parentNode)
557 if (n.parentNode == code && n != mover) return;
558
559 // See if this is a click in the gutter
560 for (var n = e_target(e); n != wrapper; n = n.parentNode)
561 if (n.parentNode == gutterText) {
562 if (options.onGutterClick)
563 options.onGutterClick(instance, indexOf(gutterText.childNodes, n) + showingFrom, e);
564 return e_preventDefault(e);
565 }
566
567 var start = posFromMouse(e);
568
569 switch (e_button(e)) {
570 case 3:
571 if (gecko && !mac) onContextMenu(e);
572 return;
573 case 2:
574 if (start) setCursor(start.line, start.ch, true);
575 setTimeout(focusInput, 20);
576 return;
577 }
578 // For button 1, if it was clicked inside the editor
579 // (posFromMouse returning non-null), we have to adjust the
580 // selection.
581 if (!start) {if (e_target(e) == scroller) e_preventDefault(e); return;}
582
583 if (!focused) onFocus();
584
585 var now = +new Date;
586 if (lastDoubleClick && lastDoubleClick.time > now - 400 && posEq(lastDoubleClick.pos, start)) {
587 e_preventDefault(e);
588 setTimeout(focusInput, 20);
589 return selectLine(start.line);
590 } else if (lastClick && lastClick.time > now - 400 && posEq(lastClick.pos, start)) {
591 lastDoubleClick = {time: now, pos: start};
592 e_preventDefault(e);
593 return selectWordAt(start);
594 } else { lastClick = {time: now, pos: start}; }
595
596 var last = start, going;
597 if (options.dragDrop && dragAndDrop && !options.readOnly && !posEq(sel.from, sel.to) &&
598 !posLess(start, sel.from) && !posLess(sel.to, start)) {
599 // Let the drag handler handle this.
600 if (webkit) lineSpace.draggable = true;
601 function dragEnd(e2) {
602 if (webkit) lineSpace.draggable = false;
603 draggingText = false;
604 up(); drop();
605 if (Math.abs(e.clientX - e2.clientX) + Math.abs(e.clientY - e2.clientY) < 10) {
606 e_preventDefault(e2);
607 setCursor(start.line, start.ch, true);
608 focusInput();
609 }
610 }

Callers

nothing calls this directly

Calls 15

setShiftFunction · 0.85
e_propFunction · 0.85
setCursorFunction · 0.85
selectWordAtFunction · 0.85
connectFunction · 0.85
e_targetFunction · 0.70
indexOfFunction · 0.70
e_preventDefaultFunction · 0.70
posFromMouseFunction · 0.70
e_buttonFunction · 0.70
onContextMenuFunction · 0.70
onFocusFunction · 0.70

Tested by

no test coverage detected