/
Focus.py
56 lines (44 loc) · 1.09 KB
/
Focus.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# FocusImplOld
def blur(elem):
JS("""
elem.blur();
""")
def createFocusable():
JS("""
var div = $doc.createElement('div');
var input = $doc.createElement('input');
input.type = 'text';
input.style.width = input.style.height = 0;
input.style.zIndex = -1;
input.style.position = 'absolute';
input.addEventListener(
'blur',
function(evt) { if (this.parentNode.onblur) this.parentNode.onblur(evt); },
false);
input.addEventListener(
'focus',
function(evt) { if (this.parentNode.onfocus) this.parentNode.onfocus(evt); },
false);
div.addEventListener(
'mousedown',
function(evt) { this.firstChild.focus(); },
false);
div.appendChild(input);
return div;
""")
def focus(elem):
JS("""
elem.focus();
""")
def getTabIndex(elem):
JS("""
return elem.firstChild.tabIndex;
""")
def setAccessKey(elem, key):
JS("""
elem.firstChild.accessKey = key;
""")
def setTabIndex(elem, index):
JS("""
elem.firstChild.tabIndex = index;
""")