Commit 8cdd0c12 authored by campaign's avatar campaign

by zhanyi

parent d44dd094
......@@ -13,7 +13,7 @@ kity.extendClass( Minder, {
},
// TODO: mousemove lazy bind
_bindPaperEvents: function () {
this._paper.on( 'click mousedown mouseup mousemove mousewheel touchstart touchmove touchend', this._firePharse.bind( this ) );
this._paper.on( 'click dblclick mousedown mouseup mousemove mousewheel touchstart touchmove touchend', this._firePharse.bind( this ) );
if ( window ) {
window.addEventListener( 'resize', this._firePharse.bind( this ) );
}
......
......@@ -27,7 +27,7 @@ KityMinder.registerModule( "TextEditModule", function () {
var textShape = node.getTextShape();
textShape.setStyle('cursor','default');
if ( this.isSingleSelect() && node.isSelected() ) {
if ( this.isSingleSelect() && node.isSelected() && e.kityEvent.targetShape.getType().toLowerCase()== 'text') {
sel.collapse();
node.getTextShape().setStyle('cursor','text');
......@@ -57,18 +57,26 @@ KityMinder.registerModule( "TextEditModule", function () {
'beforemousemove':function(e){
if(mouseDownStatus){
e.stopPropagationImmediately();
setTimeout(function(){
var offset = e.getPosition();
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();
},100)
var offset = e.getPosition();
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();
}
},
'dblclick':function(e){
var text = e.kityEvent.targetShape;
if ( text.getType().toLowerCase()== 'text') {
sel.setStartOffset(0);
sel.setEndOffset(text.getContent().length);
sel.setShow();
receiver.updateSelectionShow(1)
.updateRange(range);
}
},
'restoreScene':function(){
sel.setHide();
......
......@@ -223,6 +223,9 @@ Minder.Receiver = kity.createClass('Receiver',{
if(offset.x >= v.x && offset.x <= v.x + v.width){
if(me.index == i){
if(i == 0){
me.selection.setStartOffset(i)
}
me.selection.setEndOffset(i + (dir == 1 ? 1 : 0))
}else if(i > me.index){
me.selection.setEndOffset(i + (dir == 1 ? 1 : 0))
......@@ -236,7 +239,6 @@ Minder.Receiver = kity.createClass('Receiver',{
return this;
},
updateSelectionShow:function(){
var startOffset = this.textData[this.selection.startOffset],
endOffset = this.textData[this.selection.endOffset],
width = 0 ;
......
......@@ -86,10 +86,15 @@ Minder.Selection = kity.createClass( 'Selection', {
clearInterval( this.timer );
var me = this,
state = '';
this.timer = setInterval( function () {
me.setStyle( 'display', state );
state = state ? '' : 'none';
}, 300 );
if(this.collapsed){
this.timer = setInterval( function () {
me.setStyle( 'display', state );
state = state ? '' : 'none';
}, 300 );
}else{
me.setStyle( 'display', '' );
}
return this;
},
setTextShape: function ( text ) {
......
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