From: Bob J. <bob...@gr...> - 2005-08-10 16:21:40
|
I've been banging my head against the wall trying to get this to work, and = no luck so far. I have a child layer, in which I want to be able to click a= nd get the x and y values of where I clicked -- so far, it's getting the x = and y value relative to the page, not the layer. I'm using 3.0. What am I d= oing wrong? (This is being used in PHP, so you may see some variables that = are coming from that) var photo =3D dynapi.document.addChild(new DynLayer(null,0,0,600,400)); var bg1 =3D photo.addChild(new DynLayer(null,0,0,600,400)); bg1.setHTML('<img src=3D"$url" border=3D"1" width=3D"600" height=3D"400">'); bg1.setInnerBorder(0,{top:'black',right:'black',bottom:'black',left:'black'= }); bg1.setZIndex(2); bg1.addEventListener({ onclick:function(e){ var x =3D e.getX(); debugtext.setHTML('<span class=3D"text_11">' + x + '</span>'); lyr1.setX(x); lyr1.setY(e.getY()); document.editcamera.valueX.value =3D lyr1.getX(); document.editcamera.valueY.value =3D lyr1.getY(); } }); var lyr1 =3D photo.addChild(new DynLayer(null,$x,$y,10,10,'red')); lyr1.setZIndex(3); DragEvent.enableDragEvents(lyr1); DragEvent.setDragBoundary(lyr1, {left:0, right:0, top:0, bottom:0}); lyr1.addEventListener({ ondragend:function(e){ var o=3De.getSource(); o.setZIndex(3); document.editcamera.valueX.value =3D lyr1.getX(); document.editcamera.valueY.value =3D lyr1.getY(); } }); I have a relative layer down in the html: dynapi.document.insertChild(photo= ,'relative'); Help, please! --=20 _______________________________________________ Graffiti.net free e-mail @ www.graffiti.net Check out our value-added Premium features, such as a 1 GB mailbox for just= US$9.95 per year! Powered By Outblaze |
From: Leif W <war...@us...> - 2005-08-10 17:12:51
|
> From: "Bob Jamison" <bob...@gr...> > Sent: 2005 August 09 Tuesday 19:09 > > I have a child layer, in which I want to be able to click and get the > x and y values of where I clicked -- so far, it's getting the x and y > value relative to the page, not the layer. I'm using 3.0. Hi. Which 3.0? ;-) beta1 (2 years old) or beta2 (released last week). And which browser(s) yield the erroneous behavior? To my understanding, getX/Y is relative to parent, and getPageX/Y is relative to page. So the usage seems correct at first glance. I'll take a closer look. Hmm, what looks odd to me are these... var photo = dynapi.document.addChild( new DynLayer(null,0,0,600,400) ); var bg1 = photo.addChild(new DynLayer(null,0,0,600,400)); var lyr1 = photo.addChild(new DynLayer(null,$x,$y,10,10,'red')); Normally, I assign DynLayer directly to a variable, configure it, and when done use dynapi.document.addChild. I'll try both ways and see what happens. > I have a relative layer down in the html: > dynapi.document.insertChild(photo,'relative'); This I don't understand... you already added the DynLayer "photo" to the document once above, now you wish to insert it? So there should be two instances, is this correct? Is it even possible, again, I never tried that. :-) I'll fiddle around and get back later today. Leif |
From: Leif W <war...@us...> - 2005-08-11 01:17:10
|
> From: "Leif W" <war...@us...> > Sent: 2005 August 10 Wednesday 13:12 > >> From: "Bob Jamison" <bob...@gr...> >> Sent: 2005 August 09 Tuesday 19:09 > >> I have a child layer, in which I want to be able to click and get the >> x and y values of where I clicked -- so far, it's getting the x and y >> value relative to the page, not the layer. I'm using 3.0. I've made a simple example, which looks very much likes Doug's, so I just merged the differences. It seems to work ok for me. DynAPI: 3.0.0-beta2 Browsers: Mozilla Firefox 1.0.6, Internet Explorer 6 OS WinXP SP2 > Hmm, what looks odd to me are these... > > var photo = dynapi.document.addChild( new > DynLayer(null,0,0,600,400) ); > var bg1 = photo.addChild(new DynLayer(null,0,0,600,400)); > var lyr1 = photo.addChild(new DynLayer(null,$x,$y,10,10,'red')); Well, I'll be... hmm, I don't remember using that syntax before, but it works as I expect, so nevermind my comments. Leif |
From: <do...@cr...> - 2005-08-10 17:41:30
|
Bob, Some information that we need includes the following: The make and version of web browser you are experiencing the poroblem in. The OS on which you are running said browser. The version of DynAPI 3.. is it the beta found in the downloads section, or did you download the latest version from cvs. That said I have mashed together the following test html. In IE 6 and FireFox 1.0.6 the results are as expected. The only thing that comes to mind is maybe the fact that your photo layer is set to have an x and y of 0. Thus, if the parent layer's top left corner is at 0x0 then the x and y values of the child layer will reflect this (10 pixels from the top of a layer that is at 0px from the top of the page will be 10px from the top of the page. When I change the Photo layer's x and y to 10x10 and then move the child layer to the top-left I get x and y of 0x0 as expected. <html> <head> <script language="JavaScript" src="src/dynapi.js"></script> <script language="Javascript"> dynapi.library.setPath('src/'); dynapi.library.include('dynapi.api'); dynapi.library.include('dynapi.gui.BorderManager'); dynapi.library.include('DragEvent'); </script> <script language=javascript> var debugLayer = dynapi.document.addChild(new DynLayer(null,610,0,100,100)); var photo = dynapi.document.addChild(new DynLayer(null,10,10,600,400)); var bg1 = photo.addChild(new DynLayer(null,0,0,600,400)); bg1.setHTML('<img src="examples/images/f1-sky.jpg" border="1" width="600" height="400">'); bg1.setInnerBorder(0,{top:'black',right:'black',bottom:'black',left:'black'}); bg1.setZIndex(2); bg1.addEventListener({ onclick:function(e){ var x = e.getX(); //debugtext.setHTML('<span class="text_11">' + x + '</span>'); lyr1.setX(x); lyr1.setY(e.getY()); //document.editcamera.valueX.value = lyr1.getX(); //document.editcamera.valueY.value = lyr1.getY(); debugLayer.setHTML("X=" + lyr1.getX() + " and Y=" + lyr1.getY()) } }); var lyr1 = photo.addChild(new DynLayer(null,5,5,10,10,'red')); lyr1.setZIndex(3); DragEvent.enableDragEvents(lyr1); DragEvent.setDragBoundary(lyr1, {left:0, right:0, top:0, bottom:0}); lyr1.addEventListener({ ondragend:function(e){ var o=e.getSource(); o.setZIndex(3); //document.editcamera.valueX.value = lyr1.getX(); //document.editcamera.valueY.value = lyr1.getY(); debugLayer.setHTML("X=" + lyr1.getX() + " and Y=" + lyr1.getY()) } }); </script> </head> <body> <script language=javascript> dynapi.document.insertChild(photo,'relative'); </script> </body> </html> Bob Jamison <bob...@gr...> said: > I've been banging my head against the wall trying to get this to work, and no luck so far. I have a child layer, in which I want to be able to click and get the x and y values of where I clicked -- so far, it's getting the x and y value relative to the page, not the layer. I'm using 3.0. What am I doing wrong? (This is being used in PHP, so you may see some variables that are coming from that) > > > var photo = dynapi.document.addChild(new DynLayer(null,0,0,600,400)); > > > var bg1 = photo.addChild(new DynLayer(null,0,0,600,400)); > bg1.setHTML('<img src="$url" border="1" width="600" height="400">'); > bg1.setInnerBorder(0,{top:'black',right:'black',bottom:'black',left:'black'}); > bg1.setZIndex(2); > bg1.addEventListener({ > onclick:function(e){ > var x = e.getX(); > debugtext.setHTML('<span class="text_11">' + x + '</span>'); > lyr1.setX(x); > lyr1.setY(e.getY()); > document.editcamera.valueX.value = lyr1.getX(); > document.editcamera.valueY.value = lyr1.getY(); > } > }); > > var lyr1 = photo.addChild(new DynLayer(null,$x,$y,10,10,'red')); > lyr1.setZIndex(3); > DragEvent.enableDragEvents(lyr1); > DragEvent.setDragBoundary(lyr1, {left:0, right:0, top:0, bottom:0}); > lyr1.addEventListener({ > ondragend:function(e){ > var o=e.getSource(); > o.setZIndex(3); > document.editcamera.valueX.value = lyr1.getX(); > document.editcamera.valueY.value = lyr1.getY(); > } > }); > > > I have a relative layer down in the html: dynapi.document.insertChild(photo,'relative'); > > Help, please! > > -- > _______________________________________________ > Graffiti.net free e-mail @ www.graffiti.net > Check out our value-added Premium features, such as a 1 GB mailbox for just US$9.95 per year! > > > Powered By Outblaze > > > ------------------------------------------------------- > SF.Net email is Sponsored by the Better Software Conference & EXPO > September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices > Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA > Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf > _______________________________________________ > Dynapi-Help mailing list > Dyn...@li... > https://lists.sourceforge.net/lists/listinfo/dynapi-help > -- |
From: <do...@cr...> - 2005-08-10 17:44:54
|
P.S. You now owe me for half my lunch hour I charge 40$ Canadian per hour, so I'll expect your check or money order for 20$ If you do not comply I will send my crack team of squirrel commandos to ravage your garden and terrorize your cat. :-P Bob Jamison <bob...@gr...> said: > I've been banging my head against the wall trying to get this to work, and no luck so far. I have a child layer, in which I want to be able to click and get the x and y values of where I clicked -- so far, it's getting the x and y value relative to the page, not the layer. I'm using 3.0. What am I doing wrong? (This is being used in PHP, so you may see some variables that are coming from that) > > > var photo = dynapi.document.addChild(new DynLayer(null,0,0,600,400)); > > > var bg1 = photo.addChild(new DynLayer(null,0,0,600,400)); > bg1.setHTML('<img src="$url" border="1" width="600" height="400">'); > bg1.setInnerBorder(0,{top:'black',right:'black',bottom:'black',left:'black'}); > bg1.setZIndex(2); > bg1.addEventListener({ > onclick:function(e){ > var x = e.getX(); > debugtext.setHTML('<span class="text_11">' + x + '</span>'); > lyr1.setX(x); > lyr1.setY(e.getY()); > document.editcamera.valueX.value = lyr1.getX(); > document.editcamera.valueY.value = lyr1.getY(); > } > }); > > var lyr1 = photo.addChild(new DynLayer(null,$x,$y,10,10,'red')); > lyr1.setZIndex(3); > DragEvent.enableDragEvents(lyr1); > DragEvent.setDragBoundary(lyr1, {left:0, right:0, top:0, bottom:0}); > lyr1.addEventListener({ > ondragend:function(e){ > var o=e.getSource(); > o.setZIndex(3); > document.editcamera.valueX.value = lyr1.getX(); > document.editcamera.valueY.value = lyr1.getY(); > } > }); > > > I have a relative layer down in the html: dynapi.document.insertChild(photo,'relative'); > > Help, please! > > -- > _______________________________________________ > Graffiti.net free e-mail @ www.graffiti.net > Check out our value-added Premium features, such as a 1 GB mailbox for just US$9.95 per year! > > > Powered By Outblaze > > > ------------------------------------------------------- > SF.Net email is Sponsored by the Better Software Conference & EXPO > September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices > Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA > Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf > _______________________________________________ > Dynapi-Help mailing list > Dyn...@li... > https://lists.sourceforge.net/lists/listinfo/dynapi-help > -- |