MCPcopy
hub / github.com/nwutils/nw-sample-apps / onContextMenu

Function onContextMenu

mini-code-edit/cm/lib/codemirror.js:1683–1718  ·  view source on GitHub ↗
(e)

Source from the content-addressed store, hash-verified

1681 return coordsChar(x - offL.left, y - offL.top);
1682 }
1683 function onContextMenu(e) {
1684 var pos = posFromMouse(e), scrollPos = scroller.scrollTop;
1685 if (!pos || window.opera) return; // Opera is difficult.
1686 if (posEq(sel.from, sel.to) || posLess(pos, sel.from) || !posLess(pos, sel.to))
1687 operation(setCursor)(pos.line, pos.ch);
1688
1689 var oldCSS = input.style.cssText;
1690 inputDiv.style.position = "absolute";
1691 input.style.cssText = "position: fixed; width: 30px; height: 30px; top: " + (e.clientY - 5) +
1692 "px; left: " + (e.clientX - 5) + "px; z-index: 1000; background: white; " +
1693 "border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);";
1694 leaveInputAlone = true;
1695 var val = input.value = getSelection();
1696 focusInput();
1697 selectInput(input);
1698 function rehide() {
1699 var newVal = splitLines(input.value).join("\n");
1700 if (newVal != val) operation(replaceSelection)(newVal, "end");
1701 inputDiv.style.position = "relative";
1702 input.style.cssText = oldCSS;
1703 if (ie_lt9) scroller.scrollTop = scrollPos;
1704 leaveInputAlone = false;
1705 resetInput(true);
1706 slowPoll();
1707 }
1708
1709 if (gecko) {
1710 e_stop(e);
1711 var mouseup = connect(window, "mouseup", function() {
1712 mouseup();
1713 setTimeout(rehide, 20);
1714 }, true);
1715 } else {
1716 setTimeout(rehide, 50);
1717 }
1718 }
1719
1720 // Cursor-blinking
1721 function restartBlink() {

Callers 1

onMouseDownFunction · 0.85

Calls 10

posFromMouseFunction · 0.85
posEqFunction · 0.85
posLessFunction · 0.85
operationFunction · 0.85
getSelectionFunction · 0.85
focusInputFunction · 0.85
selectInputFunction · 0.85
e_stopFunction · 0.85
connectFunction · 0.85
mouseupFunction · 0.85

Tested by

no test coverage detected