|
4 | 4 | <html lang="en">
|
5 | 5 | <head>
|
6 | 6 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
| 7 | + <!--<meta name="viewport" content="width=device-width,height=device-height" />--> |
7 | 8 | <title>Text Events</title>
|
8 | 9 | <meta name="author" content="Fabian Jakobs">
|
9 | 10 |
|
|
20 | 21 | width: 590px;
|
21 | 22 | height: 400px;
|
22 | 23 | }
|
| 24 | + |
| 25 | + #text { |
| 26 | + position: absolute; |
| 27 | + } |
23 | 28 |
|
24 | 29 | </style>
|
25 | 30 |
|
|
70 | 75 | console.log(e.type, e.charCode, e.keyCode, e);
|
71 | 76 | }
|
72 | 77 |
|
| 78 | +addListener(canvas, "mousedown", function(e) { |
| 79 | + text.focus(); |
| 80 | + e.preventDefault(); |
| 81 | +}, false); |
| 82 | + |
| 83 | +var pos; |
| 84 | +addListener(canvas, "touchstart", function(e) { |
| 85 | + text.value = "" |
| 86 | + pos = e.touches[0] |
| 87 | + text.focus(); |
| 88 | +}, false); |
| 89 | +addListener(canvas, "contextmenu", function(e) { |
| 90 | + text.value = "xxxxx"; |
| 91 | + var rect = canvas.getBoundingClientRect() |
| 92 | + // text.selectionStart = 0 |
| 93 | + // text.selectionEnd = 20 |
| 94 | + text.style.opacity = 0 |
| 95 | + text.style.top = pos.clientY - 15 - rect.top + "px" |
| 96 | + text.style.left = pos.clientX - 15 - rect.left + "px" |
| 97 | + // canvas.style.fontSize = "300px" |
| 98 | + // text.readOnly = true |
| 99 | + // text.focus(); |
| 100 | + text.style.width = "50px" |
| 101 | + text.style.height = "50px" |
| 102 | + text.select(); |
| 103 | + setTimeout(function() { |
| 104 | + text.readOnly = false |
| 105 | + // text.style.top = pos.clientY - 5 + "px" |
| 106 | + // text.style.left = pos.clientY - 5 + "px" |
| 107 | + }, 100) |
| 108 | + //e.preventDefault(); |
| 109 | +}, false); |
| 110 | + |
73 | 111 | addListener(text, "keydown", logKey, false);
|
74 | 112 | addListener(text, "keyup", logKey, false);
|
75 | 113 | addListener(text, "keypress", logKey, false);
|
|
78 | 116 | console.log(e.type, e.data, e);
|
79 | 117 | }, false);
|
80 | 118 |
|
| 119 | +var i = 0; |
81 | 120 | function fillSelection() {
|
82 |
| - text.value = "Juhu Kinners"; |
| 121 | + text.value = "Juhu Kinners " + (i++); |
83 | 122 | text.select();
|
84 | 123 | }
|
85 | 124 |
|
|
0 commit comments