提交 0ed3078f 编写于 作者: Mr.奇淼('s avatar Mr.奇淼(

增加delete删除node功能

上级 b7cb072d
/* eslint-disable */ /* eslint-disable */
export default function(G6){ export default function(G6) {
G6.registerBehavior('deleteItem', { G6.registerBehavior('deleteItem', {
getEvents() { getEvents() {
return { return {
'keydown': 'onKeydown', 'keydown': 'onKeydown',
'canvas:mouseleave': 'onCanvasLeave', 'canvas:mouseleave': 'onCanvasLeave',
'canvas:mouseenter': 'onCanvasFocus', 'canvas:mouseenter': 'onCanvasFocus',
} }
}, },
onKeydown(e){ onKeydown(e) {
const items = this.graph.get('selectedItems'); const items = this.graph.get('selectedItems');
const focus = this.graph.get('focusGraphWrapper'); const focus = this.graph.get('focusGraphWrapper');
if(e.keyCode === 8 && items && items.length > 0 && focus){ if (e.keyCode === 46 && items && items.length > 0 && focus) {
if(this.graph.executeCommand) { if (this.graph.executeCommand) {
this.graph.executeCommand('delete', {}); this.graph.executeCommand('delete', {});
}else{ } else {
this.graph.remove(items[0]); this.graph.remove(items[0]);
}
this.graph.set('selectedItems', []);
this.graph.emit('afteritemselected', []);
}
},
onCanvasLeave(e) {
this.graph.set('focusGraphWrapper', false);
},
onCanvasFocus() {
this.graph.set('focusGraphWrapper', true);
} }
this.graph.set('selectedItems',[]); });
this.graph.emit('afteritemselected',[]); }
} \ No newline at end of file
},
onCanvasLeave(e){
this.graph.set('focusGraphWrapper',false);
},
onCanvasFocus(){
this.graph.set('focusGraphWrapper',true);
}
});
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册