This commit is contained in:
sidorares 2011-07-26 15:42:46 +10:00
commit be8a5c76d5

View file

@ -47,20 +47,52 @@ Core requsests usage:
});
Simple core requests Window wrapper:
'click&draw' demo using simple Window wrapper:
var x11 = require('x11');
var x11 = require('../lib/x11');
var Window = require('./wndwrap');
var xclient = x11.createClient();
xclient.on('connect', function(display) {
var mainwnd = new Window(xclient, 0, 0, 100, 100);
mainwnd.on('expose', function(ev) {
ev.gc.drawText(50, 50, 'Hello, NodeJS!');
});
mainwnd.map();
x11.createClient(function(display) {
var pts = [];
new Window(display.client, 0, 0, 700, 500)
.handle({
mousemove: function(ev) {
if (this.pressed)
{
var lastpoly = pts[pts.length - 1];
lastpoly.push(ev.x);
lastpoly.push(ev.y);
if (lastpoly.length > 3)
this.gc.polyLine(lastpoly.slice(-4));
}
},
mousedown: function(ev) {
if (ev.keycode == 1) { // left button
this.pressed = true;
pts.push([]); // start next polyline
}
},
mouseup: function(ev) {
if (ev.keycode == 1) // left button
this.pressed = false;
},
expose: function(ev) {
for (var i=0; i < pts.length ; ++i)
this.gc.polyLine(pts[i]);
}
})
.map()
.title = 'Hello, world!';
});
# Protocol documentation
- http://www.x.org/releases/X11R7.6/doc/