added new "reactToInput" text-editing event to Morphic

to address timing conflicts between "reactToKeystroke", which new gets triggeref before the input actually changes.
pull/89/head
jmoenig 2019-10-14 12:51:03 +02:00
rodzic 6ff5dcd6bb
commit 5bdad135ca
3 zmienionych plików z 21 dodań i 3 usunięć

Wyświetl plik

@ -15,6 +15,9 @@
* Galician, thanks, Bernat
* Turkish, thanks, Turgut!
### 2019-10-14
* morphic: new "reactToInput" text-editing event
### 2019-10-11
* objects, threads: accept a list of pixels in the SWITCH TO COSTUME block

Wyświetl plik

@ -4,7 +4,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Snap! Build Your Own Blocks 5.1.1 - dev -</title>
<link rel="shortcut icon" href="src/favicon.ico">
<script type="text/javascript" src="src/morphic.js?version=2019-08-06"></script>
<script type="text/javascript" src="src/morphic.js?version=2019-10-14"></script>
<script type="text/javascript" src="src/widgets.js?version=2019-06-27"></script>
<script type="text/javascript" src="src/blocks.js?version=2019-08-07"></script>
<script type="text/javascript" src="src/threads.js?version=2019-10-11"></script>

Wyświetl plik

@ -760,13 +760,24 @@
events:
Whenever the user presses a key on the keyboard while a text element
is being edited, a
is being edited, first a
reactToKeystroke(event)
is escalated up its parent chain, the "event" parameter being the
original one received by the World.
Whenever the input changes, by adding or removing one or more characters,
an additional
reactToInput(event)
is escalated up its parent chain, the "event" parameter again being the
original one received by the World or by the IME element.
Note that the "reactToKeystroke" event gets triggered before the input
changes, and thus befgore the "reactToInput" event fires.
Once the user has completed the edit, the following events are
dispatched:
@ -1166,7 +1177,7 @@
/*global window, HTMLCanvasElement, FileReader, Audio, FileList, Map*/
var morphicVersion = '2019-October-09';
var morphicVersion = '2019-October-14';
var modules = {}; // keep track of additional loaded modules
var useBlurredShadows = getBlurredShadowSupport(); // check for Chrome-bug
@ -5534,6 +5545,10 @@ CursorMorph.prototype.initializeTextarea = function () {
myself.gotoSlot(textarea.selectionStart);
myself.updateTextAreaPosition();
// the "reactToInput" event gets triggered AFTER "reactToKeystroke"
myself.target.escalateEvent('reactToInput', event);
});
this.textarea.addEventListener('keyup', function (event) {