Statistics
| Branch: | Tag: | Revision:

one / src / sunstone / public / vendor / noVNC / tests / input.html @ 5fcb9de8

History | View | Annotate | Download (2.39 KB)

1
<!DOCTYPE html>
2
<html>
3
    <head><title>Input Test</title></head>
4
    <body>
5
        <br><br>
6

    
7
        Canvas:<br>
8
        <canvas id="canvas" width="640" height="20"
9
                style="border-style: dotted; border-width: 1px;">
10
            Canvas not supported.
11
        </canvas>
12

    
13
        <br>
14
        Results:<br>
15
        <textarea id="messages" style="font-size: 9;" cols=80 rows=25></textarea>
16
    </body>
17

    
18
    <!--
19
    <script type='text/javascript' 
20
        src='http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js'></script>
21
    -->
22
    <script src="../include/util.js"></script>
23
    <script src="../include/webutil.js"></script> 
24
    <script src="../include/base64.js"></script>
25
    <script src="../include/input.js"></script> 
26
    <script src="../include/canvas.js"></script>
27
    <script>
28
        var msg_cnt = 0;
29
        var width = 400, height = 200;
30
        var iterations;
31

32
        var newline = "\n";
33
        if (Util.Engine.trident) {
34
            var newline = "<br>\n";
35
        }
36

37
        function message(str) {
38
            console.log(str);
39
            cell = $D('messages');
40
            cell.innerHTML += msg_cnt + ": " + str + newline;
41
            cell.scrollTop = cell.scrollHeight;
42
            msg_cnt++;
43
        }
44

45
        function mouseButton(x, y, down, bmask) {
46
            msg = 'mouse x,y: ' + x + ',' + y + '  down: ' + down;
47
            msg += ' bmask: ' + bmask;
48
            message(msg);
49
        }
50

51
        function mouseMove(x, y) {
52
            msg = 'mouse x,y: ' + x + ',' + y;
53
            //console.log(msg);
54
        }
55

56
        function keyPress(keysym, down, e) {
57
            var d = down ? "down" : " up ";
58
            msg = "keyPress " + d + " keysym: " + keysym +
59
                  " (key: " + e.keyCode + ", char: " + e.charCode +
60
                  ", which: " + e.which +")";
61
            message(msg);
62
        }
63

64
        window.onload = function() {
65
            var canvas = new Canvas({'target' : $D('canvas')});
66
            keyboard = new Keyboard({'target': document,
67
                                    'keyPress': keyPress});
68
            mouse    = new Mouse({'target': $D('canvas'),
69
                                'mouseButton': mouseButton,
70
                                'mouseMove': mouseMove});
71
            canvas.resize(width, height, true);
72
            keyboard.grab();
73
            mouse.grab();
74
            message("Canvas initialized");
75
        }
76
    </script>
77
</html>