Commit 06027381 authored by campaign's avatar campaign

by zhanyi

parent 422b339d
......@@ -12,9 +12,13 @@ KityMinder.registerModule( "TextEditModule", function () {
var lastEvtPosition,dir = 1;
km.isTextEditStatus = function(){
return km.receiver.isTextEditStatus();
}
};
return {
//插入光标
......@@ -25,12 +29,18 @@ KityMinder.registerModule( "TextEditModule", function () {
'beforemousedown':function(e){
sel.setHide();
var node = e.getTargetNode();
if(!node){
var selectionShape = e.kityEvent.targetShape;
if(selectionShape && selectionShape.getType() == 'Selection'){
node = selectionShape.getData('relatedNode');
}
}
if(node){
var textShape = node.getTextShape();
textShape.setStyle('cursor','default');
if ( this.isSingleSelect() && node.isSelected()) {// && e.kityEvent.targetShape.getType().toLowerCase()== 'text'
sel.collapse();
node.getTextShape().setStyle('cursor','text');
receiver.setTextEditStatus(true)
......@@ -44,15 +54,20 @@ KityMinder.registerModule( "TextEditModule", function () {
.setCurrentIndex(e.getPosition())
.updateSelection()
.setRange(range);
sel.setData('relatedNode',node);
mouseDownStatus = true;
lastEvtPosition = e.getPosition();
}
}
},
'mouseup':function(e){
if(!sel.collapsed && mouseDownStatus){
receiver.updateRange(range)
if(mouseDownStatus){
if(!sel.collapsed ){
receiver.updateRange(range)
}else
sel.setShow()
}
mouseDownStatus = false;
oneTime = 0;
},
......@@ -62,7 +77,7 @@ KityMinder.registerModule( "TextEditModule", function () {
var offset = e.getPosition();
if(Math.abs(offset.y - lastEvtPosition.y) > 2){
if(Math.abs(offset.y - lastEvtPosition.y) > 2 && Math.abs(lastEvtPosition.x - offset.x) < 1 ){
sel.setHide();
mouseDownStatus = false;
return;
......@@ -70,7 +85,7 @@ KityMinder.registerModule( "TextEditModule", function () {
dir = offset.x > lastEvtPosition.x ? 1 : (offset.x < lastEvtPosition.x ? -1 : dir);
receiver.updateSelectionByMousePosition(offset,dir)
.updateSelectionShow(dir);
sel.stroke('none',0);
lastEvtPosition = e.getPosition();
}
......
......@@ -5,9 +5,9 @@ Minder.Selection = kity.createClass( 'Selection', {
this.callBase();
this.height = height || 20;
this.stroke( color || 'blue', width || 1 );
this.width = 1;
this.fill('#99C8FF');
this.stroke( color || 'rgb(27,171,255)', width || 1 );
this.width = 0;
this.fill('rgb(27,171,255)');
this.setHide();
this.timer = null;
this.collapsed = true;
......@@ -17,7 +17,8 @@ Minder.Selection = kity.createClass( 'Selection', {
},
collapse : function(toEnd){
this.stroke( 'blue', 1 );
this.stroke( 'rgb(27,171,255)', 1 );
this.setOpacity(1);
this.width = 1;
this.collapsed = true;
if(toEnd){
......@@ -38,7 +39,8 @@ Minder.Selection = kity.createClass( 'Selection', {
return this;
}
this.collapsed = false;
this.stroke('none');
this.stroke('none',0);
this.setOpacity(0.5);
return this;
},
setEndOffset:function(offset){
......@@ -52,10 +54,14 @@ Minder.Selection = kity.createClass( 'Selection', {
return this;
}
this.collapsed = false;
this.stroke('none');
this.stroke('none',0);
this.setOpacity(0.5);
return this;
},
updateShow : function(offset,width){
if(width){
this.setShowHold();
}
this.setPosition(offset).setWidth(width);
return this;
},
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment