comparison nodejs/mbapp.js @ 721:01d02382dea7

Refactory the mbapp and testsvg to use keyboard events
author wycc
date Sun, 15 Aug 2010 19:07:36 +0800
parents 72abb4154936
children 503f3d18248e
comparison
equal deleted inserted replaced
720:9c5abb4e114b 721:01d02382dea7
7 paint.fill(background); 7 paint.fill(background);
8 mb_rt.root.add_shape(background); 8 mb_rt.root.add_shape(background);
9 9
10 app=function() { 10 app=function() {
11 this.mb_rt = mb_rt; 11 this.mb_rt = mb_rt;
12
13 } 12 }
14 app.prototype.loadSVG=function(fname) { 13 app.prototype.loadSVG=function(fname) {
15 svg.loadSVG(mb_rt,mb_rt.root,fname); 14 svg.loadSVG(this.mb_rt,this.mb_rt.root,fname);
16 } 15 }
17 16
18 app.prototype.loop=function() { 17 app.prototype.loop=function() {
19 mb_rt.redraw_all(); 18 this.mb_rt.redraw_all();
20 mb_rt.flush(); 19 this.mb_rt.flush();
20 }
21 app.prototype.get=function(name) {
22 return this.mb_rt.mbnames[name];
23 }
24 app.prototype.addKeyboardListener=function(type,f) {
25 return this.mb_rt.kbevents.add_event_observer(type,f);
21 } 26 }
22 27
23 exports.app=app; 28 exports.app=app;
29
30 // Put all key definition here
31 exports.KEY_UP=111;
32 exports.KEY_DOWN=116;