MCPcopy Index your code
hub / github.com/methodofaction/Method-Draw / setSelection

Function setSelection

src/js/svgcanvas.js:3505–3548  ·  view source on GitHub ↗
(start, end, skipInput)

Source from the content-addressed store, hash-verified

3503 }
3504
3505 function setSelection(start, end, skipInput) {
3506 if(start === end) {
3507 setCursor(end);
3508 return;
3509 }
3510
3511 if(!skipInput) {
3512 textinput.setSelectionRange(start, end);
3513 }
3514
3515 selblock = getElem("text_selectblock");
3516 if (!selblock) {
3517
3518 selblock = document.createElementNS(svgns, "path");
3519 assignAttributes(selblock, {
3520 'id': "text_selectblock",
3521 'fill': "blue",
3522 'opacity': .5,
3523 'style': "pointer-events:none"
3524 });
3525 getElem("selectorParentGroup").appendChild(selblock);
3526 }
3527
3528 var startbb = chardata[start];
3529 var endbb = chardata[end];
3530
3531 cursor.setAttribute('visibility', 'hidden');
3532
3533 var tl = ptToScreen(startbb.x, textbb.y),
3534 tr = ptToScreen(startbb.x + (endbb.x - startbb.x), textbb.y),
3535 bl = ptToScreen(startbb.x, textbb.y + textbb.height),
3536 br = ptToScreen(startbb.x + (endbb.x - startbb.x), textbb.y + textbb.height);
3537
3538
3539 var dstr = "M" + tl.x + "," + tl.y
3540 + " L" + tr.x + "," + tr.y
3541 + " " + br.x + "," + br.y
3542 + " " + bl.x + "," + bl.y + "z";
3543
3544 assignAttributes(selblock, {
3545 d: dstr,
3546 'display': 'inline'
3547 });
3548 }
3549
3550 function getIndexFromPoint(mouse_x, mouse_y) {
3551 // Position cursor here

Callers 4

setEndSelectionFromPointFunction · 0.85
selectAllFunction · 0.85
selectWordFunction · 0.85
svgcanvas.jsFile · 0.85

Calls 2

setCursorFunction · 0.85
ptToScreenFunction · 0.85

Tested by

no test coverage detected