handleClick()

in src/overlay/gather-markers.ts [552:579]


  handleClick(event: MouseEvent) {
    let editor = this.editor;
    if (editor.getWrapperElement().contains(event.target as Node)) {
      // In Chrome, if you click in the top of an editor's text area, it will trigger this
      // event, and is considered as a click at the start of the box. This filter for
      // span elements filters out those spurious clicks.
      let target = event.target as HTMLElement;
      let badTarget =
        !target.tagName || target.tagName != "SPAN" || !target.classList.contains(DEFINITION_CLASS);
      if (badTarget) return;
      let clickPosition: CodeMirror.Position = editor.coordsChar({
        left: event.clientX,
        top: event.clientY
      });
      let editorMarkers = editor.getDoc().findMarksAt(clickPosition);
      if (editorMarkers.indexOf(this.marker) != -1) {
        if (this.clickHandler) {
          this.toggleSelected();
          log("Clicked on definition", {
            toggledOn: this._selected,
            cell: this.cell
          });
          this.clickHandler(this.cell, this.location, this._selected, event);
        }
        event.preventDefault();
      }
    }
  }