code: function onMouseDown(e) {
      if (signalDOMEvent(this, e)) return;
      var cm = this, display = cm.display;
      display.shift = e.shiftKey;
  
      if (eventInWidget(display, e)) {
        if (!webkit) {
          // Briefly turn off draggability, to allow widgets to do
          // normal dragging things.
          display.scroller.draggable = false;
          setTimeout(function(){display.scroller.draggable = true;}, 100);
        }
        return;
      }
      if (clickInGutter(cm, e)) return;
      var start = posFromMouse(cm, e);
      window.focus();
  
      switch (e_button(e)) {
      case 1:
        if (start)
          leftButtonDown(cm, e, start);
        else if (e_target(e) == display.scroller)
          e_preventDefault(e);
        break;
      case 2:
        if (webkit) cm.state.lastMiddleDown = +new Date;
        if (start) extendSelection(cm.doc, start);
        setTimeout(bind(focusInput, cm), 20);
        e_preventDefault(e);
        break;
      case 3:
        if (captureRightClick) onContextMenu(cm, e);
        break;
      }
    }
docs: A mouse down can be a single click, double click, triple click, start of selection drag, start of text drag, new cursor (ctrl-click), rectangle drag (alt-drag), or xwin middle-click-paste. Or it might be a click on something we should not interfere with, such as a scrollbar or widget.