Skip to content
Browse files

a few improvments

  • Loading branch information...
1 parent 838f05f commit 40ed1f7418d5bb1d07b3ade73962c5adc07b3dc9 @joearms committed Feb 20, 2011
Showing with 28 additions and 8 deletions.
  1. +8 −6 svg/svg.js
  2. +20 −2 svg/svg_test.html
View
14 svg/svg.js
@@ -200,11 +200,9 @@ function SVG(pageId){
case "configure": C.configure(o); break;
default: alert("bad o.cmd ="+o.cmd);
};
- // log("i="+i+" type="+o.cmd);
- // log("i="+i+" o.clickable = "+o.clickable);
- // val.setAttribute("id", o.id);
if(o.clickable){
- log("clickable "+o.id + "val="+val);
+ log("clickable "+o.id + "val="+o.msg);
+ val.setAttribute("message", D(o.msg, "void"));
val.addEventListener("mousedown",
function(evt){was_clicked(evt)},
false);
@@ -215,8 +213,12 @@ function SVG(pageId){
function was_clicked(evt)
{
obj = evt.target;
- var id = obj.getAttribute("id");
- svg_event({pageid:C.pageId, id:id, type:"clicked"});
+ var id = obj.getAttribute("id");
+ var msg = obj.getAttribute("message");
+ var str = "clicked?page=" +
+ "&id=" + escape(id) +
+ "&msg=" + escape(msg);
+ svg_event(str);
};
function mouse_down(evt)
View
22 svg/svg_test.html
@@ -1,6 +1,10 @@
<script src="svg.js"></script>
<script>
+ function svg_event(x){
+ log("event:" + x);
+ }
+
function log(x){
document.getElementById("logger").innerHTML += x + "<br>";
}
@@ -9,8 +13,9 @@
var cmds =
[
{cmd:"mk_canvas",id:1, width:800, ht:500, color:"#acacac"},
- {cmd:"mk_rect", parent:1, id:2, x:10, y:10,
- width:100, ht:50, color:"red"},
+ {cmd:"mk_rect", parent:1, id:2, x:10, y:10, width:100, ht:50, color:"red"},
+ {cmd:"mk_rect", parent:1, id:22, x:110, y:10, width:100, ht:30, color:"pink",
+ clickable:true, msg:"pinkclick"},
{cmd:"mk_circle", parent:1, x:30, y:90, r:20, color:"black"},
{cmd:"mk_text", parent:1, x:60, y:160, size:8, str:"Hello",
font:"Times"},
@@ -48,5 +53,18 @@
<li>Blue drag circle</li>
<li>Draggable image</li>
<div id="a1"></div>
+ <h2>Notes</h2>
+ <p>Q: How should we interact with the svg canvas?
+ <br>A: By sending JSON messages.
+ <p>Q: What objects are clickabkle?
+ <br>A: Only buttons. If we can make anthing clickabkle then it
+ will not be obvious.
+ <p>Q: What objects are draggable?
+ <br>A: Only drag squares. Again it should be obvious what objects are draggable.
+ <p>Q: What are the drag methods?
+ <br>A: on_drag_start/on_moved/on_dropped
+
+
<div id="logger"></div>
+
</body>

0 comments on commit 40ed1f7

Please sign in to comment.
Something went wrong with that request. Please try again.