OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <html> |
| 3 <!-- |
| 4 Copyright (c) 2011 The Native Client Authors. All rights reserved. |
| 5 Use of this source code is governed by a BSD-style license that can be |
| 6 found in the LICENSE file. |
| 7 --> |
| 8 <head> |
| 9 <title>PPAPI InputEvent test</title> |
| 10 |
| 11 <script type="text/javascript"> |
| 12 function $(id) { |
| 13 return document.getElementById(id); |
| 14 } |
| 15 |
| 16 var events = ''; |
| 17 |
| 18 function receiveMessage(message) { |
| 19 events += message.data; |
| 20 } |
| 21 |
| 22 function getEvents() { |
| 23 try { |
| 24 var event_dump = $('event_dump'); |
| 25 event_dump.firstChild.nodeValue = events; |
| 26 events = ''; |
| 27 } catch(e) { |
| 28 alert(e.message); |
| 29 } |
| 30 } |
| 31 </script> |
| 32 </head> |
| 33 <body> |
| 34 <h1>InputEvent Handling Example</h1> |
| 35 <div id="listener"> |
| 36 <script type="text/javascript"> |
| 37 $('listener').addEventListener('message', receiveMessage, true); |
| 38 </script> |
| 39 |
| 40 <embed name="nacl_module" |
| 41 id="event_module" |
| 42 width=400 height=400 |
| 43 src="ppapi_example_events.nmf" |
| 44 type="application/x-nacl" |
| 45 style="background-color:gray" /> |
| 46 </div> |
| 47 <p> |
| 48 This example demonstrates handling of input events in PPAPI. |
| 49 <p> |
| 50 Each time an input event happens in the context of the gray box, |
| 51 the embedded NaCl module prints a message describing the event to the shell |
| 52 where you started your Browser. |
| 53 <p> |
| 54 Alternatively, you can click the "Get Events" button to display |
| 55 all input events that have happened since the last time you clicked the |
| 56 button. |
| 57 </p> |
| 58 <form name="event_form" action="" method="get"> |
| 59 <input type="button" value="Get Events" onclick="getEvents()"/> |
| 60 </form> |
| 61 |
| 62 <h2>Recent Events (press button to update):</h2> |
| 63 <pre id=event_dump> |
| 64 no events |
| 65 </pre> |
| 66 </body> |
| 67 </html> |
OLD | NEW |