diff --git a/src/morphic.js b/src/morphic.js index 5d38243f..11217b14 100644 --- a/src/morphic.js +++ b/src/morphic.js @@ -5421,7 +5421,7 @@ CursorMorph.prototype.initializeTextarea = function () { // For other keyboard events, first let the textarea element handle the // events, then we take its state and update the target morph and cursor // morph accordingly. - this.textarea.addEventListener('keyup', function (event) { + this.textarea.addEventListener('input', function (event) { myself.world().currentKey = null; var target = myself.target; @@ -5461,6 +5461,7 @@ CursorMorph.prototype.initializeTextarea = function () { } // target morph: copy the content and selection status to the target. target.text = filteredContent; + if (textarea.selectionStart === textarea.selectionEnd) { target.startMark = null; target.endMark = null; @@ -5481,7 +5482,29 @@ CursorMorph.prototype.initializeTextarea = function () { myself.gotoSlot(textarea.selectionStart); myself.updateTextAreaPosition(); - target.escalateEvent('reactToKeystroke', event); + //target.escalateEvent('reactToKeystroke', event); + }); + + this.textarea.addEventListener('keyup', function (event) { + var textarea = myself.textarea; + var target = myself.target; + + if (textarea.selectionStart === textarea.selectionEnd) { + target.startMark = null; + target.endMark = null; + } else { + if (textarea.selectionDirection === 'backward') { + target.startMark = textarea.selectionEnd; + target.endMark = textarea.selectionStart; + } else { + target.startMark = textarea.selectionStart; + target.endMark = textarea.selectionEnd; + } + } + target.changed(); + target.drawNew(); + target.changed(); + myself.gotoSlot(textarea.selectionEnd); }); };