Commit 8cdd0c12 authored by campaign's avatar campaign

by zhanyi

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