From b3fc9e8f8b0583cbd5b3be94a8b5523df354b326 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Sat, 17 Dec 2011 11:03:39 +0900 Subject: [PATCH] make sure element is visible on focus change --- aqt/editor.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/aqt/editor.py b/aqt/editor.py index 454660c71..a4c54d0a6 100644 --- a/aqt/editor.py +++ b/aqt/editor.py @@ -88,6 +88,14 @@ function onFocus(elem) { $(elem).css("-webkit-user-select", "none"); setTimeout(function () { unfocusHack() }, 1); py.run("focus:" + currentField.id.substring(1)); + function pos(obj) { + var cur = 0; + do { + cur += obj.offsetTop; + } while (obj = obj.offsetParent); + return cur; + } + window.scroll(0,pos(elem)-15); } // restore cursor