Fixed issue 694 and some other related text bugs
git-svn-id: http://svg-edit.googlecode.com/svn/trunk@1763 eee81c28-f429-11dd-99c0-75d572ba1ddd
This commit is contained in:
@@ -5139,9 +5139,6 @@ var getMouseTarget = this.getMouseTarget = function(evt) {
|
|||||||
if (selectedElements[0].nodeName == "path" && selectedElements[1] == null) {
|
if (selectedElements[0].nodeName == "path" && selectedElements[1] == null) {
|
||||||
pathActions.select(t);
|
pathActions.select(t);
|
||||||
} // if it was a path
|
} // if it was a path
|
||||||
else if (selectedElements[0].nodeName == "text" && selectedElements[1] == null) {
|
|
||||||
textActions.select(t, x, y);
|
|
||||||
} // if it was a path
|
|
||||||
// else, if it was selected and this is a shift-click, remove it from selection
|
// else, if it was selected and this is a shift-click, remove it from selection
|
||||||
else if (evt.shiftKey) {
|
else if (evt.shiftKey) {
|
||||||
if(tempJustSelected != t) {
|
if(tempJustSelected != t) {
|
||||||
@@ -5239,7 +5236,7 @@ var getMouseTarget = this.getMouseTarget = function(evt) {
|
|||||||
break;
|
break;
|
||||||
case "text":
|
case "text":
|
||||||
keep = true;
|
keep = true;
|
||||||
addToSelection([element]);
|
selectOnly([element]);
|
||||||
textActions.start(element);
|
textActions.start(element);
|
||||||
break;
|
break;
|
||||||
case "path":
|
case "path":
|
||||||
@@ -5319,6 +5316,7 @@ var getMouseTarget = this.getMouseTarget = function(evt) {
|
|||||||
|
|
||||||
} else if (element != null) {
|
} else if (element != null) {
|
||||||
canvas.addedNew = true;
|
canvas.addedNew = true;
|
||||||
|
|
||||||
var ani_dur = .2, c_ani;
|
var ani_dur = .2, c_ani;
|
||||||
if(opac_ani.beginElement && element.getAttribute('opacity') != cur_shape.opacity) {
|
if(opac_ani.beginElement && element.getAttribute('opacity') != cur_shape.opacity) {
|
||||||
c_ani = $(opac_ani).clone().attr({
|
c_ani = $(opac_ani).clone().attr({
|
||||||
@@ -5365,6 +5363,11 @@ var getMouseTarget = this.getMouseTarget = function(evt) {
|
|||||||
|
|
||||||
var mouse_target = getMouseTarget(evt);
|
var mouse_target = getMouseTarget(evt);
|
||||||
|
|
||||||
|
if(mouse_target.tagName === 'text' && current_mode !== 'textedit') {
|
||||||
|
var pt = transformPoint( evt.pageX, evt.pageY, root_sctm );
|
||||||
|
textActions.select(mouse_target, pt.x, pt.y);
|
||||||
|
}
|
||||||
|
|
||||||
if(getRotationAngle(mouse_target)) {
|
if(getRotationAngle(mouse_target)) {
|
||||||
// Don't do for rotated groups for now
|
// Don't do for rotated groups for now
|
||||||
return;
|
return;
|
||||||
@@ -5437,7 +5440,7 @@ var preventClickDefault = function(img) {
|
|||||||
// Group: Text edit functions
|
// Group: Text edit functions
|
||||||
// Functions relating to editing text elements
|
// Functions relating to editing text elements
|
||||||
var textActions = canvas.textActions = function() {
|
var textActions = canvas.textActions = function() {
|
||||||
var curtext, current_text;
|
var curtext;
|
||||||
var textinput;
|
var textinput;
|
||||||
var cursor;
|
var cursor;
|
||||||
var selblock;
|
var selblock;
|
||||||
@@ -5556,7 +5559,6 @@ var textActions = canvas.textActions = function() {
|
|||||||
|
|
||||||
// No content, so return 0
|
// No content, so return 0
|
||||||
if(chardata.length == 1) return 0;
|
if(chardata.length == 1) return 0;
|
||||||
|
|
||||||
// Determine if cursor should be on left or right of character
|
// Determine if cursor should be on left or right of character
|
||||||
var charpos = curtext.getCharNumAtPosition(pt);
|
var charpos = curtext.getCharNumAtPosition(pt);
|
||||||
if(charpos < 0) {
|
if(charpos < 0) {
|
||||||
@@ -5637,7 +5639,7 @@ var textActions = canvas.textActions = function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function selectWord(evt) {
|
function selectWord(evt) {
|
||||||
if(!allow_dbl) return;
|
if(!allow_dbl || !curtext) return;
|
||||||
|
|
||||||
var ept = transformPoint( evt.pageX, evt.pageY, root_sctm ),
|
var ept = transformPoint( evt.pageX, evt.pageY, root_sctm ),
|
||||||
mouse_x = ept.x * current_zoom,
|
mouse_x = ept.x * current_zoom,
|
||||||
@@ -5661,13 +5663,8 @@ var textActions = canvas.textActions = function() {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
select: function(target, x, y) {
|
select: function(target, x, y) {
|
||||||
if (current_text == target) {
|
curtext = target;
|
||||||
curtext = target;
|
textActions.toEditMode(x, y);
|
||||||
textActions.toEditMode(x, y);
|
|
||||||
} // going into pathedit mode
|
|
||||||
else {
|
|
||||||
current_text = target;
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
start: function(elem) {
|
start: function(elem) {
|
||||||
curtext = elem;
|
curtext = elem;
|
||||||
@@ -5711,6 +5708,7 @@ var textActions = canvas.textActions = function() {
|
|||||||
var sel = selectorManager.requestSelector(curtext).selectorRect;
|
var sel = selectorManager.requestSelector(curtext).selectorRect;
|
||||||
|
|
||||||
textActions.init();
|
textActions.init();
|
||||||
|
|
||||||
$(curtext).css('cursor', 'text');
|
$(curtext).css('cursor', 'text');
|
||||||
|
|
||||||
// if(support.editableText) {
|
// if(support.editableText) {
|
||||||
@@ -5762,7 +5760,6 @@ var textActions = canvas.textActions = function() {
|
|||||||
// $(textinput).blur(hideCursor);
|
// $(textinput).blur(hideCursor);
|
||||||
},
|
},
|
||||||
clear: function() {
|
clear: function() {
|
||||||
current_text = null;
|
|
||||||
if(current_mode == "textedit") {
|
if(current_mode == "textedit") {
|
||||||
textActions.toSelectMode();
|
textActions.toSelectMode();
|
||||||
}
|
}
|
||||||
@@ -5820,7 +5817,6 @@ var textActions = canvas.textActions = function() {
|
|||||||
x: end.x,
|
x: end.x,
|
||||||
width: 0
|
width: 0
|
||||||
});
|
});
|
||||||
|
|
||||||
setSelection(textinput.selectionStart, textinput.selectionEnd, true);
|
setSelection(textinput.selectionStart, textinput.selectionEnd, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user