diff --git a/static/application.js b/static/application.js index 83b4376b..e6c05c08 100644 --- a/static/application.js +++ b/static/application.js @@ -977,7 +977,7 @@ function chunkOnPaste(event) { } // This gets run every time the caret moves in the editor -function chunkOnSelectionChange(event) { +function _chunkOnSelectionChange(event, do_blur_focus) { if(!gametext_bound || !allowedit || override_focusout) { override_focusout = false; return; @@ -988,7 +988,7 @@ function chunkOnSelectionChange(event) { highlightEditingChunks(); // Attempt to prevent Chromium-based browsers on Android from // scrolling away from the current selection - if(!using_webkit_patch) { + if(do_blur_focus && !using_webkit_patch) { setTimeout(function() { game_text.blur(); game_text.focus(); @@ -998,6 +998,14 @@ function chunkOnSelectionChange(event) { }, 2); } +function chunkOnSelectionChange(event) { + return _chunkOnSelectionChange(event, true); +} + +function chunkOnKeyDownSelectionChange(event) { + return _chunkOnSelectionChange(event, false); +} + // This gets run when you defocus the editor by clicking // outside of the editor or by pressing escape or tab function chunkOnFocusOut(event) { @@ -1432,7 +1440,7 @@ $(document).ready(function(){ ).on('click', chunkOnSelectionChange ).on('keydown', - chunkOnSelectionChange + chunkOnKeyDownSelectionChange ).on('focusout', chunkOnFocusOut );