Commit dd8bb74c authored by campaign's avatar campaign

模拟光标这个整体调整

parent 38a32e73
......@@ -176,6 +176,10 @@ var Minder = KityMinder.Minder = kity.createClass('KityMinder', {
},
setStatus: function(status) {
if (status) {
this.fire('statuschange',{
lastStatus:this._status,
currentStatus:status
});
this._rollbackStatus = this._status;
this._status = status;
} else {
......
......@@ -316,6 +316,9 @@ var TreeDragger = kity.createClass('TreeDragger', {
_renderOrderHint: function(hint) {
this._orderHinter.render(hint);
},
preventDragMove:function(){
this._startPosition = null;
}
});
......@@ -340,6 +343,11 @@ KityMinder.registerModule('DragTree', function() {
dragger.dragEnd(e.getPosition(this.getRenderContainer()));
e.stopPropagation();
this.fire('contentchange');
},
'statuschange':function(e){
if(e.lastStatus == 'textedit' && e.currentStatus == 'normal'){
dragger.preventDragMove();
}
}
},
commands: {
......
......@@ -40,7 +40,6 @@ KityMinder.registerModule('TextEditModule', function() {
'events': {
'ready': function() {
this._renderTarget.appendChild(receiver.container);
this.getRenderContainer().addShape(sel);
},
'normal.beforemousedown textedit.beforemousedown inputready.beforemousedown': function(e) {
......@@ -73,7 +72,6 @@ KityMinder.registerModule('TextEditModule', function() {
var textShape = node.getTextShape();
textShape.setStyle('cursor', 'default');
if (this.isSingleSelect() && node.isSelected()) {
sel.collapse();
......@@ -182,6 +180,8 @@ KityMinder.registerModule('TextEditModule', function() {
inputStatusReady(e.getTargetNode());
km.setStatus('textedit');
receiver.updateSelectionShow();
},
// 'restoreScene': function() {
......@@ -226,7 +226,7 @@ KityMinder.registerModule('TextEditModule', function() {
};
if (cmds[e.commandName]) {
inputStatusReady(km.getSelectedNode());
selectionReadyShow = true;
receiver.updateSelectionShow();
return;
}
......@@ -236,18 +236,11 @@ KityMinder.registerModule('TextEditModule', function() {
this.setStatus('normal');
}
},
'layoutapply':function(e){
'layoutfinish':function(e){
if (e.node === receiver.minderNode && (this.getStatus() == 'textedit' || this.getStatus() == 'inputready') ) {//&& selectionReadyShow
receiver
.setBaseOffset()
.setContainerStyle()
.updateTextOffsetData();
if (sel.collapsed) {
receiver.updateSelection();
} else {
receiver.updateSelectionShow();
}
.setContainerStyle();
}
},
......
......@@ -61,16 +61,14 @@ Minder.Receiver = kity.createClass('Receiver', {
getTextShapeHeight: function() {
return this.textShape.getRenderBox().height;
},
appendTextShapeToPaper: function(paper) {
paper.addShape(this.textShape);
return this;
},
setKityMinder: function(km) {
this.km = km;
return this;
},
setMinderNode: function(node) {
this.minderNode = node;
//追加selection到节点
this._addSelection();
//更新minderNode下的textshape
this.setTextShape(node.getTextShape());
//更新textshape的baseOffset
......@@ -86,6 +84,10 @@ Minder.Receiver = kity.createClass('Receiver', {
return this;
},
_addSelection:function(){
if (this.selection.container) this.selection.remove();
this.minderNode.getRenderContainer().addShape(this.selection);
},
getMinderNode:function(){
return this.minderNode;
},
......@@ -119,7 +121,7 @@ Minder.Receiver = kity.createClass('Receiver', {
me.minderNode.render();
clearTimeout(me.inputTextTimer);
me.inputTextTimer = setTimeout(function(){
me.km.layout();
me.km.layout(300);
},250);
me.textShape = me.minderNode.getRenderer('TextRenderer').getRenderShape();
......@@ -314,8 +316,8 @@ Minder.Receiver = kity.createClass('Receiver', {
}
this.textData.push({
x: box.x + this.offset.x,
y: this.offset.y,
x: box.x ,
y: box.y,
width: box.width,
height: box.height
});
......@@ -326,6 +328,8 @@ Minder.Receiver = kity.createClass('Receiver', {
var me = this;
this.getTextOffsetData();
var hadChanged = false;
//要剪掉基数
this._getRelativeValue(offset);
utils.each(this.textData, function(i, v) {
//点击开始之前
if (i === 0 && offset.x <= v.x) {
......@@ -356,9 +360,13 @@ Minder.Receiver = kity.createClass('Receiver', {
this.selection.setHeight(this.getTextShapeHeight());
return this;
},
_getRelativeValue:function(offset){
offset.x = offset.x - this.offset.x;
offset.y = offset.y - this.offset.y;
},
updateSelectionByMousePosition: function(offset, dir) {
//要剪掉基数
this._getRelativeValue(offset);
var me = this;
utils.each(this.textData, function(i, v) {
//点击开始之前
......@@ -435,7 +443,7 @@ Minder.Receiver = kity.createClass('Receiver', {
return this;
},
updateContainerRangeBySel:function(){
this.updateRange(this.range)
this.updateRange(this.range);
},
setIndex: function(index) {
this.index = index;
......
......@@ -15,7 +15,7 @@ Minder.Selection = kity.createClass( 'Selection', {
this.setOpacity(0.5);
this.setStyle('cursor','text');
this._show = false;
this.selectionShowStatus = true;
},
collapse : function(toEnd){
......@@ -121,19 +121,5 @@ Minder.Selection = kity.createClass( 'Selection', {
},
isHide:function(){
return !this._show;
},
setTextShape: function ( text ) {
if ( !text ) {
this.text = new kity.Text();
} else {
this.text = text;
}
return this;
},
getTextShape: function () {
return this.text;
},
setTxtContent: function ( text ) {
this.text.setContent( text );
}
} );
\ No newline at end of file
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