Skip to content

Commit

Permalink
a few improvments
Browse files Browse the repository at this point in the history
  • Loading branch information
joearms committed Feb 20, 2011
1 parent 838f05f commit 40ed1f7
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 8 deletions.
14 changes: 8 additions & 6 deletions svg/svg.js
Expand Up @@ -200,11 +200,9 @@ function SVG(pageId){
case "configure": C.configure(o); break; case "configure": C.configure(o); break;
default: alert("bad o.cmd ="+o.cmd); 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){ 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", val.addEventListener("mousedown",
function(evt){was_clicked(evt)}, function(evt){was_clicked(evt)},
false); false);
Expand All @@ -215,8 +213,12 @@ function SVG(pageId){
function was_clicked(evt) function was_clicked(evt)
{ {
obj = evt.target; obj = evt.target;
var id = obj.getAttribute("id"); var id = obj.getAttribute("id");
svg_event({pageid:C.pageId, id:id, type:"clicked"}); var msg = obj.getAttribute("message");
var str = "clicked?page=" +
"&id=" + escape(id) +
"&msg=" + escape(msg);
svg_event(str);
}; };


function mouse_down(evt) function mouse_down(evt)
Expand Down
22 changes: 20 additions & 2 deletions svg/svg_test.html
@@ -1,6 +1,10 @@
<script src="svg.js"></script> <script src="svg.js"></script>
<script> <script>


function svg_event(x){
log("event:" + x);
}

function log(x){ function log(x){
document.getElementById("logger").innerHTML += x + "<br>"; document.getElementById("logger").innerHTML += x + "<br>";
} }
Expand All @@ -9,8 +13,9 @@
var cmds = var cmds =
[ [
{cmd:"mk_canvas",id:1, width:800, ht:500, color:"#acacac"}, {cmd:"mk_canvas",id:1, width:800, ht:500, color:"#acacac"},
{cmd:"mk_rect", parent:1, id:2, x:10, y:10, {cmd:"mk_rect", parent:1, id:2, x:10, y:10, width:100, ht:50, color:"red"},
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_circle", parent:1, x:30, y:90, r:20, color:"black"},
{cmd:"mk_text", parent:1, x:60, y:160, size:8, str:"Hello", {cmd:"mk_text", parent:1, x:60, y:160, size:8, str:"Hello",
font:"Times"}, font:"Times"},
Expand Down Expand Up @@ -48,5 +53,18 @@ <h2>Propertis</h2>
<li>Blue drag circle</li> <li>Blue drag circle</li>
<li>Draggable image</li> <li>Draggable image</li>
<div id="a1"></div> <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> <div id="logger"></div>

</body> </body>

0 comments on commit 40ed1f7

Please sign in to comment.