blob: 3f1695d0d03397fd2c71a5dde86dba7453812de1 (
plain)
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
55
56
57
58
|
<!DOCTYPE html>
<html>
<!--
Copyright (c) 2011 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
-->
<head>
<title>Input Events</title>
<script type="text/javascript">
var kMaxArraySize = 20;
var messageArray = new Array();
function $(id) {
return document.getElementById(id);
}
function receiveMessage(message) {
// Show last |kMaxArraySize| events in html.
messageArray.push(message.data);
if (messageArray.length > kMaxArraySize) {
messageArray.shift();
}
var newData = messageArray.join('<BR>');
document.getElementById('eventString').innerHTML = newData;
// Print event to console.
console.log(message.data);
}
</script>
</head>
<body>
<h1>InputEvent Handling Example</h1>
<div id="listener">
<script type="text/javascript">
$('listener').addEventListener('message', receiveMessage, true);
</script>
<embed name="nacl_module"
id="event_module"
width=400 height=400
src="input_events.nmf"
type="application/x-nacl"
style="background-color:gray" />
</div>
<p>
This example demonstrates handling of input events in PPAPI.</p>
<p>
Each time an input event happens in the context of the gray box,
the embedded NaCl module posts a message describing the event
back to JavaScript, which prints a message to the JavaScript
console in Chrome and to a string on the page.</p>
<h2>Events</h2>
<pre>
<p><b id='eventString'>None</b></p>
</pre>
</body>
</html>
|