Merge pull request #1985 from ajaxorg/focus
fix issue with scrolling into view on focus
This commit is contained in:
commit
5496351529
2 changed files with 27 additions and 19 deletions
|
|
@ -26,28 +26,32 @@
|
||||||
<div class="scrollmargin"></div>
|
<div class="scrollmargin"></div>
|
||||||
<pre id="editor"></pre>
|
<pre id="editor"></pre>
|
||||||
|
|
||||||
<script src="../build/src/ace.js"></script>
|
<script src="kitchen-sink/require.js"></script>
|
||||||
<script>
|
<script>
|
||||||
|
// setup paths
|
||||||
|
require.config({paths: { "ace" : "../lib/ace"}});
|
||||||
|
// load ace and extensions
|
||||||
|
require(["ace/ace"], function(ace) {
|
||||||
|
|
||||||
var editor1 = ace.edit("editor1");
|
var editor1 = ace.edit("editor1");
|
||||||
editor1.setTheme("ace/theme/tomorrow_night_eighties");
|
editor1.setTheme("ace/theme/tomorrow_night_eighties");
|
||||||
editor1.session.setMode("ace/mode/html");
|
editor1.session.setMode("ace/mode/html");
|
||||||
editor1.setAutoScrollEditorIntoView(true);
|
editor1.setAutoScrollEditorIntoView(true);
|
||||||
editor1.setOption("maxLines", 30);
|
editor1.setOption("maxLines", 30);
|
||||||
|
|
||||||
var editor2 = ace.edit("editor2");
|
var editor2 = ace.edit("editor2");
|
||||||
editor2.setTheme("ace/theme/tomorrow_night_blue");
|
editor2.setTheme("ace/theme/tomorrow_night_blue");
|
||||||
editor2.session.setMode("ace/mode/html");
|
editor2.session.setMode("ace/mode/html");
|
||||||
editor2.setAutoScrollEditorIntoView(true);
|
editor2.setAutoScrollEditorIntoView(true);
|
||||||
editor2.setOption("maxLines", 30);
|
editor2.setOption("maxLines", 30);
|
||||||
editor2.setOption("minLines", 2);
|
editor2.setOption("minLines", 2);
|
||||||
|
|
||||||
var editor = ace.edit("editor");
|
|
||||||
editor.setTheme("ace/theme/tomorrow");
|
|
||||||
editor.session.setMode("ace/mode/html");
|
|
||||||
editor.setAutoScrollEditorIntoView(true);
|
|
||||||
editor.setOption("maxLines", 100);
|
|
||||||
|
|
||||||
|
var editor = ace.edit("editor");
|
||||||
|
editor.setTheme("ace/theme/tomorrow");
|
||||||
|
editor.session.setMode("ace/mode/html");
|
||||||
|
editor.setAutoScrollEditorIntoView(true);
|
||||||
|
editor.setOption("maxLines", 100);
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script src="./show_own_source.js"></script>
|
<script src="./show_own_source.js"></script>
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,11 @@ var MouseHandler = function(editor) {
|
||||||
new DefaultGutterHandler(this);
|
new DefaultGutterHandler(this);
|
||||||
new DragdropHandler(this);
|
new DragdropHandler(this);
|
||||||
|
|
||||||
var focusEditor = function(e) { editor.focus() };
|
var focusEditor = function(e) {
|
||||||
|
if (!editor.isFocused() && editor.textInput)
|
||||||
|
editor.textInput.onContextMenu(e);
|
||||||
|
editor.focus()
|
||||||
|
};
|
||||||
|
|
||||||
var mouseTarget = editor.renderer.getMouseEventTarget();
|
var mouseTarget = editor.renderer.getMouseEventTarget();
|
||||||
event.addListener(mouseTarget, "click", this.onMouseEvent.bind(this, "click"));
|
event.addListener(mouseTarget, "click", this.onMouseEvent.bind(this, "click"));
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue