path select bugfix

master
Mark MacKay 2012-07-30 16:05:13 -05:00
parent 784d95a13a
commit e3bfdd9534
4 changed files with 8 additions and 8 deletions

View File

@ -3207,7 +3207,7 @@ var getMouseTarget = this.getMouseTarget = function(evt) {
{
canvas.addClones = false;
window.removeEventListener("keyup", canvas.removeClones)
selectedElements = selectedElements.filter(Boolean)
if(evt.button === 2) return;
var tempJustSelected = justSelected;
justSelected = null;
@ -3239,7 +3239,7 @@ var getMouseTarget = this.getMouseTarget = function(evt) {
case "select":
if (selectedElements[0] != null) {
// if we only have one selected element
if (selectedElements[1] == null) {
if (selectedElements.length == 1) {
// set our current stroke/fill properties to the element's
var selected = selectedElements[0];
switch ( selected.tagName ) {

View File

@ -260,8 +260,8 @@ if(n.gridSnapping){x=wa(x);F=wa(F);y=wa(y);C=wa(C)}k=Math.abs(h-F);v=Math.abs(m-
k+" ";G.setAttributeNS(null,"points",e);break;case "path":case "pathedit":x*=o;y*=o;if(n.gridSnapping){x=wa(x);y=wa(y);h=wa(h);m=wa(m)}if(u.shiftKey){if(F=svgedit.path.path){G=F.dragging?F.dragging[0]:h;F=F.dragging?F.dragging[1]:m}else{G=h;F=m}C=ba(G,F,x,y);x=C.x;y=C.y}if(ta&&ta.getAttribute("display")!=="none"){L*=o;k*=o;ma(ta,{x:Math.min(z*o,L),y:Math.min(w*o,k),width:Math.abs(L-z*o),height:Math.abs(k-w*o)},100)}Ja.mouseMove(u,x,y);break;case "textedit":x*=o;y*=o;hb.mouseMove(D,I);break;case "rotate":L=
svgedit.utilities.getBBox(E);F=L.x+L.width/2;C=L.y+L.height/2;G=X(E);G=M(F,C,G);F=G.x;C=G.y;G=L.x;k=L.y;if(current_rotate_mode=="nw")G=L.x+L.width;if(current_rotate_mode=="se")k=L.y+L.height;if(current_rotate_mode=="sw"){G=L.x+L.width;k=L.y+L.height}compensation_angle=(Math.atan2(C-k,F-G)*(180/Math.PI)-90)%360;S=(Math.atan2(C-y,F-x)*(180/Math.PI)-90)%360;S+=compensation_angle;if(n.gridSnapping)S=wa(S);if(u.shiftKey)S=Math.round(S/45)*45;c.setRotationAngle(S<-180?360+S:S,true);N("transition",J)}ob("mouseMove",
{event:u,mouse_x:D,mouse_y:I,selected:E})}}).click(function(u){u.preventDefault();return false}).dblclick(function(u){var E=u.target.parentNode;if(E!==K){var I=Ib(u),D=I.tagName;if(D==="text"&&Ea!=="textedit"){u=M(u.pageX,u.pageY,rb);hb.select(I,u.x,u.y)}if((D==="g"||D==="a")&&pa(I)){Mb(I);I=J[0];Qa(true)}K&&Jb();E.tagName!=="g"&&E.tagName!=="a"||E===B().getCurrentLayer()||I===Ha.selectorParentGroup||Rb(I)}}).mouseup(function(u){c.addClones=false;window.removeEventListener("keyup",c.removeClones);
if(u.button!==2){var E=Bb;Bb=null;if(La){var I=M(u.pageX,u.pageY,rb),D=I.x*o;I=I.y*o;var G=D/o,L=I/o,k=ra(ca()),v=false;La=false;switch(Ea){case "resize":case "multiselect":if(ta!=null){ta.setAttribute("display","none");mb=[]}Ea="select";case "select":if(J[0]!=null){if(J[1]==null){D=J[0];switch(D.tagName){case "g":case "use":case "image":case "foreignObject":break;default:bb.fill=D.getAttribute("fill");bb.fill_opacity=D.getAttribute("fill-opacity");bb.stroke=D.getAttribute("stroke");bb.stroke_opacity=
D.getAttribute("stroke-opacity");bb.stroke_width=D.getAttribute("stroke-width");bb.stroke_dasharray=D.getAttribute("stroke-dasharray");bb.stroke_linejoin=D.getAttribute("stroke-linejoin");bb.stroke_linecap=D.getAttribute("stroke-linecap")}if(D.tagName=="text"){Za.font_size=D.getAttribute("font-size");Za.font_family=D.getAttribute("font-family")}Ha.requestSelector(D).showGrips(true)}Ga();if(G!=z||L!=w){u=J.length;for(D=0;D<u;++D){if(J[D]==null)break;J[D].firstChild||Ha.requestSelector(J[D]).resize()}}else{D=
J=J.filter(Boolean);if(u.button!==2){var E=Bb;Bb=null;if(La){var I=M(u.pageX,u.pageY,rb),D=I.x*o;I=I.y*o;var G=D/o,L=I/o,k=ra(ca()),v=false;La=false;switch(Ea){case "resize":case "multiselect":if(ta!=null){ta.setAttribute("display","none");mb=[]}Ea="select";case "select":if(J[0]!=null){if(J.length==1){D=J[0];switch(D.tagName){case "g":case "use":case "image":case "foreignObject":break;default:bb.fill=D.getAttribute("fill");bb.fill_opacity=D.getAttribute("fill-opacity");bb.stroke=D.getAttribute("stroke");
bb.stroke_opacity=D.getAttribute("stroke-opacity");bb.stroke_width=D.getAttribute("stroke-width");bb.stroke_dasharray=D.getAttribute("stroke-dasharray");bb.stroke_linejoin=D.getAttribute("stroke-linejoin");bb.stroke_linecap=D.getAttribute("stroke-linecap")}if(D.tagName=="text"){Za.font_size=D.getAttribute("font-size");Za.font_family=D.getAttribute("font-family")}Ha.requestSelector(D).showGrips(true)}Ga();if(G!=z||L!=w){u=J.length;for(D=0;D<u;++D){if(J[D]==null)break;J[D].firstChild||Ha.requestSelector(J[D]).resize()}}else{D=
u.target;if(J[0].nodeName==="path"&&J[1]==null)Ja.select(J[0]);else u.shiftKey&&E!=D&&c.removeFromSelection([D])}if(svgedit.browser.supportsNonScalingStroke())if(u=J[0]){u.removeAttribute("style");svgedit.utilities.walkTree(u,function(P){P.removeAttribute("style")})}}return;case "zoom":ta!=null&&ta.setAttribute("display","none");N("zoomed",{x:Math.min(z,G),y:Math.min(w,L),width:Math.abs(G-z),height:Math.abs(L-w),factor:u.altKey?0.5:2});return;case "fhpath":E=k.getAttribute("points");G=E.indexOf(",");
if(v=G>=0?E.indexOf(",",G+1)>=0:E.indexOf(" ",E.indexOf(" ")+1)>=0)k=Ja.smoothPolylineIntoPath(k);break;case "line":E=$(k).attr(["x1","x2","y1","y2"]);v=E.x1!=E.x2||E.y1!=E.y2;break;case "foreignObject":case "square":case "rect":case "image":E=$(k).attr(["width","height"]);v=E.width!=0||E.height!=0||Ea==="image";break;case "circle":v=k.getAttribute("r")!=0;break;case "ellipse":E=$(k).attr(["rx","ry"]);v=E.rx!=null||E.ry!=null;break;case "fhellipse":if(A.maxx-A.minx>0&&A.maxy-A.miny>0){k=Q({element:"ellipse",
curStyles:true,attr:{cx:(A.minx+A.maxx)/2,cy:(A.miny+A.maxy)/2,rx:(A.maxx-A.minx)/2,ry:(A.maxy-A.miny)/2,id:ca()}});N("changed",[k]);v=true}break;case "fhrect":if(A.maxx-A.minx>0&&A.maxy-A.miny>0){k=Q({element:"rect",curStyles:true,attr:{x:A.minx,y:A.miny,width:A.maxx-A.minx,height:A.maxy-A.miny,id:ca()}});N("changed",[k]);v=true}break;case "text":v=true;xb([k]);hb.start(k);break;case "path":k=null;La=true;E=Ja.mouseUp(u,k,D,I);k=E.element;v=E.keep;break;case "pathedit":v=true;k=null;Ja.mouseUp(u);

View File

@ -3207,7 +3207,7 @@ var getMouseTarget = this.getMouseTarget = function(evt) {
{
canvas.addClones = false;
window.removeEventListener("keyup", canvas.removeClones)
selectedElements = selectedElements.filter(Boolean)
if(evt.button === 2) return;
var tempJustSelected = justSelected;
justSelected = null;
@ -3239,7 +3239,7 @@ var getMouseTarget = this.getMouseTarget = function(evt) {
case "select":
if (selectedElements[0] != null) {
// if we only have one selected element
if (selectedElements[1] == null) {
if (selectedElements.length == 1) {
// set our current stroke/fill properties to the element's
var selected = selectedElements[0];
switch ( selected.tagName ) {

View File

@ -260,8 +260,8 @@ if(n.gridSnapping){x=wa(x);F=wa(F);y=wa(y);C=wa(C)}k=Math.abs(h-F);v=Math.abs(m-
k+" ";G.setAttributeNS(null,"points",e);break;case "path":case "pathedit":x*=o;y*=o;if(n.gridSnapping){x=wa(x);y=wa(y);h=wa(h);m=wa(m)}if(u.shiftKey){if(F=svgedit.path.path){G=F.dragging?F.dragging[0]:h;F=F.dragging?F.dragging[1]:m}else{G=h;F=m}C=ba(G,F,x,y);x=C.x;y=C.y}if(ta&&ta.getAttribute("display")!=="none"){L*=o;k*=o;ma(ta,{x:Math.min(z*o,L),y:Math.min(w*o,k),width:Math.abs(L-z*o),height:Math.abs(k-w*o)},100)}Ja.mouseMove(u,x,y);break;case "textedit":x*=o;y*=o;hb.mouseMove(D,I);break;case "rotate":L=
svgedit.utilities.getBBox(E);F=L.x+L.width/2;C=L.y+L.height/2;G=X(E);G=M(F,C,G);F=G.x;C=G.y;G=L.x;k=L.y;if(current_rotate_mode=="nw")G=L.x+L.width;if(current_rotate_mode=="se")k=L.y+L.height;if(current_rotate_mode=="sw"){G=L.x+L.width;k=L.y+L.height}compensation_angle=(Math.atan2(C-k,F-G)*(180/Math.PI)-90)%360;S=(Math.atan2(C-y,F-x)*(180/Math.PI)-90)%360;S+=compensation_angle;if(n.gridSnapping)S=wa(S);if(u.shiftKey)S=Math.round(S/45)*45;c.setRotationAngle(S<-180?360+S:S,true);N("transition",J)}ob("mouseMove",
{event:u,mouse_x:D,mouse_y:I,selected:E})}}).click(function(u){u.preventDefault();return false}).dblclick(function(u){var E=u.target.parentNode;if(E!==K){var I=Ib(u),D=I.tagName;if(D==="text"&&Ea!=="textedit"){u=M(u.pageX,u.pageY,rb);hb.select(I,u.x,u.y)}if((D==="g"||D==="a")&&pa(I)){Mb(I);I=J[0];Qa(true)}K&&Jb();E.tagName!=="g"&&E.tagName!=="a"||E===B().getCurrentLayer()||I===Ha.selectorParentGroup||Rb(I)}}).mouseup(function(u){c.addClones=false;window.removeEventListener("keyup",c.removeClones);
if(u.button!==2){var E=Bb;Bb=null;if(La){var I=M(u.pageX,u.pageY,rb),D=I.x*o;I=I.y*o;var G=D/o,L=I/o,k=ra(ca()),v=false;La=false;switch(Ea){case "resize":case "multiselect":if(ta!=null){ta.setAttribute("display","none");mb=[]}Ea="select";case "select":if(J[0]!=null){if(J[1]==null){D=J[0];switch(D.tagName){case "g":case "use":case "image":case "foreignObject":break;default:bb.fill=D.getAttribute("fill");bb.fill_opacity=D.getAttribute("fill-opacity");bb.stroke=D.getAttribute("stroke");bb.stroke_opacity=
D.getAttribute("stroke-opacity");bb.stroke_width=D.getAttribute("stroke-width");bb.stroke_dasharray=D.getAttribute("stroke-dasharray");bb.stroke_linejoin=D.getAttribute("stroke-linejoin");bb.stroke_linecap=D.getAttribute("stroke-linecap")}if(D.tagName=="text"){Za.font_size=D.getAttribute("font-size");Za.font_family=D.getAttribute("font-family")}Ha.requestSelector(D).showGrips(true)}Ga();if(G!=z||L!=w){u=J.length;for(D=0;D<u;++D){if(J[D]==null)break;J[D].firstChild||Ha.requestSelector(J[D]).resize()}}else{D=
J=J.filter(Boolean);if(u.button!==2){var E=Bb;Bb=null;if(La){var I=M(u.pageX,u.pageY,rb),D=I.x*o;I=I.y*o;var G=D/o,L=I/o,k=ra(ca()),v=false;La=false;switch(Ea){case "resize":case "multiselect":if(ta!=null){ta.setAttribute("display","none");mb=[]}Ea="select";case "select":if(J[0]!=null){if(J.length==1){D=J[0];switch(D.tagName){case "g":case "use":case "image":case "foreignObject":break;default:bb.fill=D.getAttribute("fill");bb.fill_opacity=D.getAttribute("fill-opacity");bb.stroke=D.getAttribute("stroke");
bb.stroke_opacity=D.getAttribute("stroke-opacity");bb.stroke_width=D.getAttribute("stroke-width");bb.stroke_dasharray=D.getAttribute("stroke-dasharray");bb.stroke_linejoin=D.getAttribute("stroke-linejoin");bb.stroke_linecap=D.getAttribute("stroke-linecap")}if(D.tagName=="text"){Za.font_size=D.getAttribute("font-size");Za.font_family=D.getAttribute("font-family")}Ha.requestSelector(D).showGrips(true)}Ga();if(G!=z||L!=w){u=J.length;for(D=0;D<u;++D){if(J[D]==null)break;J[D].firstChild||Ha.requestSelector(J[D]).resize()}}else{D=
u.target;if(J[0].nodeName==="path"&&J[1]==null)Ja.select(J[0]);else u.shiftKey&&E!=D&&c.removeFromSelection([D])}if(svgedit.browser.supportsNonScalingStroke())if(u=J[0]){u.removeAttribute("style");svgedit.utilities.walkTree(u,function(P){P.removeAttribute("style")})}}return;case "zoom":ta!=null&&ta.setAttribute("display","none");N("zoomed",{x:Math.min(z,G),y:Math.min(w,L),width:Math.abs(G-z),height:Math.abs(L-w),factor:u.altKey?0.5:2});return;case "fhpath":E=k.getAttribute("points");G=E.indexOf(",");
if(v=G>=0?E.indexOf(",",G+1)>=0:E.indexOf(" ",E.indexOf(" ")+1)>=0)k=Ja.smoothPolylineIntoPath(k);break;case "line":E=$(k).attr(["x1","x2","y1","y2"]);v=E.x1!=E.x2||E.y1!=E.y2;break;case "foreignObject":case "square":case "rect":case "image":E=$(k).attr(["width","height"]);v=E.width!=0||E.height!=0||Ea==="image";break;case "circle":v=k.getAttribute("r")!=0;break;case "ellipse":E=$(k).attr(["rx","ry"]);v=E.rx!=null||E.ry!=null;break;case "fhellipse":if(A.maxx-A.minx>0&&A.maxy-A.miny>0){k=Q({element:"ellipse",
curStyles:true,attr:{cx:(A.minx+A.maxx)/2,cy:(A.miny+A.maxy)/2,rx:(A.maxx-A.minx)/2,ry:(A.maxy-A.miny)/2,id:ca()}});N("changed",[k]);v=true}break;case "fhrect":if(A.maxx-A.minx>0&&A.maxy-A.miny>0){k=Q({element:"rect",curStyles:true,attr:{x:A.minx,y:A.miny,width:A.maxx-A.minx,height:A.maxy-A.miny,id:ca()}});N("changed",[k]);v=true}break;case "text":v=true;xb([k]);hb.start(k);break;case "path":k=null;La=true;E=Ja.mouseUp(u,k,D,I);k=E.element;v=E.keep;break;case "pathedit":v=true;k=null;Ja.mouseUp(u);