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

Function setCursor

src/js/svgcanvas.js:3453–3503  ·  view source on GitHub ↗
(index)

Source from the content-addressed store, hash-verified

3451 var allow_dbl;
3452
3453 function setCursor(index) {
3454 var empty = (textinput.value === "");
3455 $(textinput).focus();
3456
3457 if(!arguments.length) {
3458 if(empty) {
3459 index = 0;
3460 } else {
3461 if(textinput.selectionEnd !== textinput.selectionStart) return;
3462 index = textinput.selectionEnd;
3463 }
3464 }
3465
3466 var charbb;
3467 charbb = chardata[index];
3468 if (!charbb) return;
3469 if(!empty) {
3470 textinput.setSelectionRange(index, index);
3471 }
3472 cursor = getElem("text_cursor");
3473 if (!cursor) {
3474 cursor = document.createElementNS(svgns, "line");
3475 assignAttributes(cursor, {
3476 'id': "text_cursor",
3477 'stroke': "#333",
3478 'stroke-width': 1
3479 });
3480 cursor = getElem("selectorParentGroup").appendChild(cursor);
3481 }
3482
3483 if(!blinker) {
3484 blinker = setInterval(function() {
3485 var show = (cursor.getAttribute('display') === 'none');
3486 cursor.setAttribute('display', show ? 'inline': 'none');
3487 }, 600);
3488 }
3489
3490 var start_pt = ptToScreen(charbb.x, textbb.y);
3491 var end_pt = ptToScreen(charbb.x, (textbb.y + textbb.height));
3492
3493 assignAttributes(cursor, {
3494 x1: start_pt.x,
3495 y1: start_pt.y,
3496 x2: end_pt.x,
3497 y2: end_pt.y,
3498 visibility: 'visible',
3499 display: 'inline'
3500 });
3501
3502 if(selblock) selblock.setAttribute('d', 'M 0 0');
3503 }
3504
3505 function setSelection(start, end, skipInput) {
3506 if(start === end) {

Callers 3

setSelectionFunction · 0.85
setCursorFromPointFunction · 0.85
svgcanvas.jsFile · 0.85

Calls 2

$Function · 0.85
ptToScreenFunction · 0.85

Tested by

no test coverage detected