Mercurial > MadButterfly
comparison nodejs/mbapp.js @ 872:bcc63b20d5c6
mbapp.js support to create an application with existed window
author | Thinker K.F. Li <thinker@codemud.net> |
---|---|
date | Fri, 24 Sep 2010 16:00:04 +0800 |
parents | 7eb5421a9864 |
children | 881efcd8a18f |
comparison
equal
deleted
inserted
replaced
871:67d0fed24120 | 872:bcc63b20d5c6 |
---|---|
67 this.keymap[k] = f; | 67 this.keymap[k] = f; |
68 } | 68 } |
69 } | 69 } |
70 } | 70 } |
71 | 71 |
72 var app_with_win = function(display, win) { | |
73 var self = this; | |
74 var mb_rt; | |
75 var background; | |
76 var paint; | |
77 | |
78 if(typeof display == "undefined" || typeof win == "undefined") | |
79 throw "Invalid argument"; | |
80 | |
81 mb_rt = this.mb_rt = new mbfly.mb_rt_with_win(display, win); | |
82 background = mb_rt.rect_new(0, 0, 720, 480, 0, 0); | |
83 paint = mb_rt.paint_color_new(1, 1, 1, 1); | |
84 paint.fill(background); | |
85 mb_rt.root.add_shape(background); | |
86 | |
87 this.mb_rt.kbevents. | |
88 add_event_observer(exports.EVT_KB_PRESS, | |
89 function(evt) { self.KeyPress(evt); }); | |
90 this.keymap = {}; | |
91 this.onKeyPress = null; | |
92 } | |
93 | |
94 app_with_win.prototype = app.prototype; | |
95 | |
72 exports.app=app; | 96 exports.app=app; |
97 exports.app_with_win = app_with_win; | |
73 | 98 |
74 // Put all key definition here | 99 // Put all key definition here |
75 exports.KEY_LEFT = 0xff51; | 100 exports.KEY_LEFT = 0xff51; |
76 exports.KEY_UP = 0xff52; | 101 exports.KEY_UP = 0xff52; |
77 exports.KEY_RIGHT = 0xff53; | 102 exports.KEY_RIGHT = 0xff53; |