MCPcopy
hub / github.com/methodofaction/Method-Draw / selectWord

Function selectWord

src/js/svgcanvas.js:3637–3658  ·  view source on GitHub ↗
(evt)

Source from the content-addressed store, hash-verified

3635 }
3636
3637 function selectWord(evt) {
3638 if(!allow_dbl || !curtext) return;
3639
3640 var ept = transformPoint( evt.pageX, evt.pageY, root_sctm ),
3641 mouse_x = ept.x * current_zoom,
3642 mouse_y = ept.y * current_zoom;
3643 var pt = screenToPt(mouse_x, mouse_y);
3644
3645 var index = getIndexFromPoint(pt.x, pt.y);
3646 var str = curtext.textContent;
3647 var first = str.substr(0, index).replace(/[a-z0-9]+$/i, '').length;
3648 var m = str.substr(index).match(/^[a-z0-9]+/i);
3649 var last = (m?m[0].length:0) + index;
3650 setSelection(first, last);
3651
3652 // Set tripleclick
3653 $(evt.target).click(selectAll);
3654 setTimeout(function() {
3655 $(evt.target).unbind('click', selectAll);
3656 }, 300);
3657
3658 }
3659
3660 return {
3661 select: function(target, x, y) {

Callers

nothing calls this directly

Calls 4

screenToPtFunction · 0.85
getIndexFromPointFunction · 0.85
setSelectionFunction · 0.85
$Function · 0.85

Tested by

no test coverage detected