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

Function posFromMouse

tools/pythonauto/static/codemirrorepl/codemirrorepl.js:1871–1882  ·  view source on GitHub ↗
(e, liberal)

Source from the content-addressed store, hash-verified

1869 function paddingLeft() {return lineSpace.offsetLeft;}
1870
1871 function posFromMouse(e, liberal) {
1872 var offW = eltOffset(scroller, true), x, y;
1873 // Fails unpredictably on IE[67] when mouse is dragged around quickly.
1874 try { x = e.clientX; y = e.clientY; } catch (e) { return null; }
1875 // This is a mess of a heuristic to try and determine whether a
1876 // scroll-bar was clicked or not, and to return null if one was
1877 // (and !liberal).
1878 if (!liberal && (x - offW.left > scroller.clientWidth || y - offW.top > scroller.clientHeight))
1879 return null;
1880 var offL = eltOffset(lineSpace, true);
1881 return coordsChar(x - offL.left, y - offL.top);
1882 }
1883 function onContextMenu(e) {
1884 var pos = posFromMouse(e), scrollPos = scroller.scrollTop;
1885 if (!pos || window.opera) return; // Opera is difficult.

Callers 6

onMouseDownFunction · 0.70
extendFunction · 0.70
doneFunction · 0.70
onDoubleClickFunction · 0.70
onDropFunction · 0.70
onContextMenuFunction · 0.70

Calls 2

eltOffsetFunction · 0.85
coordsCharFunction · 0.70

Tested by

no test coverage detected