diff nodejs/testdesktop.js @ 847:dfe28355bded

Fix the location of the text elements.
author wycc
date Sun, 19 Sep 2010 19:28:33 +0800
parents 2101a355acba
children d1c98eb474e1 c385493e04b6
line wrap: on
line diff
--- a/nodejs/testdesktop.js	Sun Sep 19 11:38:17 2010 +0800
+++ b/nodejs/testdesktop.js	Sun Sep 19 19:28:33 2010 +0800
@@ -15,15 +15,18 @@
 picture = app.get("picture");
 setting = app.get("setting");
 
+lightbar = app.get("lightbar");
+lines=[app.get("line1"),app.get("line2"),app.get("line3"), app.get("line4"),app.get("line5")];
+for(i=0;i<lines.length;i++) {
+    sys.puts("["+i+"]="+lines[i].y);
+}
+line=0;
+
 items=[video,audio,picture,setting];
 item = 0;
 an = new animate.scale(app,items[item],1,1.5,0.1);
 an.start();
 app.refresh();
-setInterval(function() {
-    
-
-}, 300);
 app.addKeyListener(mbapp.KEY_LEFT, function() {
 	var old = items[item];
 	item = item - 1;
@@ -52,6 +55,35 @@
         an.start();
 });
 
+app.addKeyListener(mbapp.KEY_UP, function() {
+	var old = lines[line];
+	line = line - 1;
+	if (line == -1) {
+		line = 0;
+		return;
+	}
+        var target = lines[line];
+	var sy = target.y-20-lightbar.y;
+	sys.puts(sy);
+	var an = new animate.linear(app,lightbar,0,sy,0.3);
+        an.start();
+});
+app.addKeyListener(mbapp.KEY_DOWN, function() {
+	var old = lines[line];
+	line = line + 1;
+	if (line == lines.length) {
+		line = line - 1; 
+		return;
+	}
+        var target = lines[line];
+	var sy = target.y-20-lightbar.y;
+	sys.puts("line="+line);
+	sys.puts("sy="+sy);
+	sys.puts("target.y="+target.y);
+	sys.puts("lightbar.y="+lightbar.y);
+	var an = new animate.linear(app,lightbar,0,sy,0.3);
+        an.start();
+});
 
 app.addKeyListener(mbapp.KEY_ENTER, function() {
 	var target = items[item];