MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / onTouchSelect

Method onTouchSelect

tools/xsbug/CodeView.js:446–466  ·  view source on GitHub ↗
(code, x, y)

Source from the content-addressed store, hash-verified

444 code.stop();
445 }
446 onTouchSelect(code, x, y) {
447 var anchor = this.anchor;
448 var bounds = code.bounds;
449 var offset = code.hitOffset(x - bounds.x, y - bounds.y);
450 if (this.mode == LINE_MODE) {
451 if (anchor.from < offset)
452 offset = code.findLineBreak(offset, true);
453 else
454 offset = code.findLineBreak(offset, false);
455 }
456 else if (this.mode == WORD_MODE) {
457 if (anchor.from < offset)
458 offset = code.findWordBreak(offset, true);
459 else
460 offset = code.findWordBreak(offset, false);
461 }
462 if (anchor.from < offset)
463 code.select(anchor.from, offset - anchor.from);
464 else
465 code.select(offset, anchor.to - offset);
466 }
467 onUndisplayed(code) {
468 this.notifier.close();
469 this.notifier = null;

Callers 2

onTimeChangedMethod · 0.95
onTouchMovedMethod · 0.95

Calls 1

selectMethod · 0.45

Tested by

no test coverage detected