This ensures that the stopping point of the scrollbar is beyond the length of
the contents that it is scrolling, and that when scrolling is calculated, it
will now account for the presence of a scrollbar. This allows
you to scroll a little extra so you can always see all content.
Fixes#2468Fixes#638Fixes#804
accordingly.
2. The textarea still listens to "keydown" and "keyup" events, for the following puerpose:
"keydown" event handler will detech some system shortcuts, add will pass it to "the world".
"keyup" event handler is used to capture the change of selection status and cursor position of the
textarea (which is not captured in the above "input" event), and update the target morphic.
I assumed that all editing start with the whold content being selected.
The project note editor shows that this assumption might not be sure.
Added code in initializeTextarea to get the cursor right at the start
of editing.
1. Design Outline:
Three parties are involved:
- the target: the StringMorph/TextMorph to be edited
- the editor: the hidden textarea
- the manager: the CursorMorph
The manager takes care of the lifecycle of the editor, and provide visual
presentation of the cursor.
The editor holds the content being edited, handles keyboard events, perform
the required editing, then update the target with the result of editing.
The target handles mouse events, which result into changes of cursor position
and selection status, then it will update the editor with these information.
2. Change of WorldMorph.edit(target) method
At the start of the method, added two guards to check:
- if `target` is actually currently being edited, do nothing.
- if another morph is being edited, call stopEditing().
- ... the old codes
This is to fix a bug in mouse event handling. The bug is that shift+click does not
select the text between the clicked position and previous position, instead
all text wiil be selected.
The cause of this bug is the morph that being edited called stopEditing() and then
.edit(), which starts a new editing session, and the previous selection state is lost.
By adding above mentioned guard, the force restart will be avoid.