Commit 2c4bd20a authored by campaign's avatar campaign

修改了select功能

parent 1a6a1dce
...@@ -31,20 +31,17 @@ kity.extendClass( Minder, function () { ...@@ -31,20 +31,17 @@ kity.extendClass( Minder, function () {
} ); } );
this._selectedNodes = []; this._selectedNodes = [];
}, },
select: function ( nodes ) { select: function ( nodes,isToggleSelect ) {
this.removeAllSelectedNodes(); isToggleSelect && this.removeAllSelectedNodes();
var me = this; var me = this;
Utils.each( Utils.isArray( nodes ) ? nodes : [ nodes ], function ( i, n ) { Utils.each( Utils.isArray( nodes ) ? nodes : [ nodes ], function ( i, n ) {
if ( me._selectedNodes.indexOf( n ) !== -1 )return;
me._selectedNodes.push( n ); me._selectedNodes.push( n );
highlightNode( me, n ); highlightNode( me, n );
} ); } );
return this; return this;
}, },
addSelect: function ( node ) {
var me = this;
if ( me._selectedNodes.indexOf( node ) === -1 ) me._selectedNodes.push( node );
highlightNode( me, node );
},
isNodeSelected: function ( node ) { isNodeSelected: function ( node ) {
return node.getData( 'highlight' ) === true; return node.getData( 'highlight' ) === true;
}, },
......
...@@ -10,44 +10,45 @@ KityMinder.registerModule( "TextEditModule", function () { ...@@ -10,44 +10,45 @@ KityMinder.registerModule( "TextEditModule", function () {
this.getPaper().addShape(cursor); this.getPaper().addShape(cursor);
}, },
"events": { "events": {
'aftermousedown':function(e){ 'beforemousedown':function(e){
if(this.isSingleSelect()){ //
debugger // if(this.isSingleSelect()){
var node = this.getSelectedNode(); // console.log('isSelect')
var node_rc = node.getRenderContainer(); // var node = this.getSelectedNode();
var position = e.getPosition(); // var node_rc = node.getRenderContainer();
if(node_rc.getType() != 'Text'){ // var position = e.getPosition();
var offset = e.getPosition(); // if(node_rc.getType() != 'Text'){
cursor.setShow().setPosition(offset); // var offset = e.getPosition();
// receiver.clear() // cursor.setShow().setPosition(offset);
// .setTextShape() //// receiver.clear()
// .setTextShapeSize(cursor.height) //// .setTextShape()
// .appendTextShapeToPaper(this.getPaper()) //// .setTextShapeSize(cursor.height)
// .setPosition(position) //// .appendTextShapeToPaper(this.getPaper())
// .setRange(range,0) //// .setPosition(position)
// .setCursor(cursor) //// .setRange(range,0)
receiver.setCursor(cursor) //// .setCursor(cursor)
.setKityMinder(this)
.setMinderNode(node)
.setTextShape(node_rc)
.setCursorHeight()
.setCurrentIndex(position)
.updateCursor()
.setRange(range,0);
}else{
// receiver.setCursor(cursor) // receiver.setCursor(cursor)
// .setKityMinder(this) // .setKityMinder(this)
// .setMinderNode(e.getTargetNode()) // .setMinderNode(node)
// .setTextShape(node_rc) // .setTextShape(node_rc)
// .setCursorHeight() // .setCursorHeight()
// .setCurrentIndex(position) // .setCurrentIndex(position)
// .updateCursor() // .updateCursor()
// .setRange(range); // .setRange(range,0);
// }else{
} //
} //
//// receiver.setCursor(cursor)
//// .setKityMinder(this)
//// .setMinderNode(e.getTargetNode())
//// .setTextShape(node_rc)
//// .setCursorHeight()
//// .setCurrentIndex(position)
//// .updateCursor()
//// .setRange(range);
//
// }
// }
} }
} }
......
...@@ -85,7 +85,7 @@ KityMinder.registerModule( "LayoutModule", function () { ...@@ -85,7 +85,7 @@ KityMinder.registerModule( "LayoutModule", function () {
execute: function ( km, node ) { execute: function ( km, node ) {
var parent = km.getSelectedNode(); var parent = km.getSelectedNode();
km.appendChildNode( parent, node ); km.appendChildNode( parent, node );
km.select( node ); km.select( node,true );
return node; return node;
} }
}; };
...@@ -100,7 +100,7 @@ KityMinder.registerModule( "LayoutModule", function () { ...@@ -100,7 +100,7 @@ KityMinder.registerModule( "LayoutModule", function () {
} else { } else {
km.appendSiblingNode( selectedNode, node ); km.appendSiblingNode( selectedNode, node );
} }
km.select( node ); km.select( node,true );
return node; return node;
} }
}; };
......
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