支持双击事件
This commit is contained in:
parent
22a418d87e
commit
54efd71c7e
|
@ -39,6 +39,10 @@ class Demo1 extends Component {
|
||||||
};
|
};
|
||||||
// this.setState({checkedKeys:cks});
|
// this.setState({checkedKeys:cks});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onDoubleClick=(key,treeNode)=>{
|
||||||
|
console.log('---onDblClick---'+key+'--treeNode--'+treeNode);
|
||||||
|
}
|
||||||
render() {
|
render() {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -48,9 +52,9 @@ class Demo1 extends Component {
|
||||||
defaultCheckedKeys = {this.state.defaultCheckedKeys}
|
defaultCheckedKeys = {this.state.defaultCheckedKeys}
|
||||||
checkStrictly
|
checkStrictly
|
||||||
onSelect={this.onSelect} onCheck={this.onCheck}
|
onSelect={this.onSelect} onCheck={this.onCheck}
|
||||||
|
onDoubleClick={this.onDoubleClick}
|
||||||
>
|
>
|
||||||
<TreeNode title="parent 1" key="0-0">
|
<TreeNode title="parent 1" key="0-0" onDoubleClick={this.onDoubleClick}>
|
||||||
<TreeNode title="parent 1-0" key="0-0-0" disabled>
|
<TreeNode title="parent 1-0" key="0-0-0" disabled>
|
||||||
<TreeNode title="leaf" key="0-0-0-0" disableCheckbox />
|
<TreeNode title="leaf" key="0-0-0-0" disableCheckbox />
|
||||||
<TreeNode title="leaf" key="0-0-0-1" />
|
<TreeNode title="leaf" key="0-0-0-1" />
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -6589,4 +6589,19 @@ input.u-button[type="submit"] {
|
||||||
right: 7px;
|
right: 7px;
|
||||||
color: rgba(0, 0, 0, 0.65); }
|
color: rgba(0, 0, 0, 0.65); }
|
||||||
|
|
||||||
|
.u-tree-searchable-filter {
|
||||||
|
color: #f50;
|
||||||
|
transition: all .3s ease; }
|
||||||
|
|
||||||
|
.title-middle {
|
||||||
|
display: inline-block;
|
||||||
|
vertical-align: middle; }
|
||||||
|
|
||||||
|
.edit-icon {
|
||||||
|
float: right;
|
||||||
|
font-size: 14px; }
|
||||||
|
|
||||||
|
.title-con {
|
||||||
|
min-width: 150px; }
|
||||||
|
|
||||||
/*# sourceMappingURL=demo.css.map */
|
/*# sourceMappingURL=demo.css.map */
|
||||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -34,6 +34,7 @@
|
||||||
|onDragLeave|当拖拽离开触发的方法|function({event,node})|-
|
|onDragLeave|当拖拽离开触发的方法|function({event,node})|-
|
||||||
|onDragEnd|当拖拽结束触发的方法|function({event,node})|-
|
|onDragEnd|当拖拽结束触发的方法|function({event,node})|-
|
||||||
|onDrop|当节点放下触发方法|function({event, node, dragNode, dragNodesKeys})|-
|
|onDrop|当节点放下触发方法|function({event, node, dragNode, dragNodesKeys})|-
|
||||||
|
|onDoubleClick|当双击发生触发的方法|function(checkedKeys, e:{node, event})|-
|
||||||
|
|
||||||
## TreeNode
|
## TreeNode
|
||||||
|参数|说明|类型|默认值|
|
|参数|说明|类型|默认值|
|
||||||
|
|
12
src/Tree.js
12
src/Tree.js
|
@ -311,6 +311,17 @@ class Tree extends React.Component {
|
||||||
props.onSelect(selectedKeys, newSt);
|
props.onSelect(selectedKeys, newSt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
onDoubleClick(treeNode){
|
||||||
|
const props = this.props;
|
||||||
|
const eventKey = treeNode.props.eventKey;
|
||||||
|
const newSt = {
|
||||||
|
event: 'dblclick',
|
||||||
|
node: treeNode
|
||||||
|
};
|
||||||
|
props.onDoubleClick(eventKey,newSt);
|
||||||
|
}
|
||||||
|
|
||||||
onMouseEnter(e, treeNode) {
|
onMouseEnter(e, treeNode) {
|
||||||
this.props.onMouseEnter({
|
this.props.onMouseEnter({
|
||||||
event: e,
|
event: e,
|
||||||
|
@ -499,6 +510,7 @@ class Tree extends React.Component {
|
||||||
onMouseEnter: props.onMouseEnter,
|
onMouseEnter: props.onMouseEnter,
|
||||||
onMouseLeave: props.onMouseLeave,
|
onMouseLeave: props.onMouseLeave,
|
||||||
onRightClick: props.onRightClick,
|
onRightClick: props.onRightClick,
|
||||||
|
onDoubleClick:props.onDoubleClick,
|
||||||
prefixCls: props.prefixCls,
|
prefixCls: props.prefixCls,
|
||||||
showLine: props.showLine,
|
showLine: props.showLine,
|
||||||
showIcon: props.showIcon,
|
showIcon: props.showIcon,
|
||||||
|
|
|
@ -28,6 +28,7 @@ class TreeNode extends React.Component {
|
||||||
'onDragLeave',
|
'onDragLeave',
|
||||||
'onDrop',
|
'onDrop',
|
||||||
'onDragEnd',
|
'onDragEnd',
|
||||||
|
'onDoubleClick'
|
||||||
].forEach((m) => {
|
].forEach((m) => {
|
||||||
this[m] = this[m].bind(this);
|
this[m] = this[m].bind(this);
|
||||||
});
|
});
|
||||||
|
@ -51,11 +52,25 @@ class TreeNode extends React.Component {
|
||||||
// }
|
// }
|
||||||
|
|
||||||
onCheck() {
|
onCheck() {
|
||||||
|
|
||||||
this.props.root.onCheck(this);
|
this.props.root.onCheck(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
onSelect() {
|
onSelect() {
|
||||||
this.props.root.onSelect(this);
|
clearTimeout(this.doubleClickFlag);
|
||||||
|
let _this = this;
|
||||||
|
//执行延时
|
||||||
|
this.doubleClickFlag = setTimeout(function(){
|
||||||
|
//do function在此处写单击事件要执行的代码
|
||||||
|
_this.props.root.onSelect(_this);
|
||||||
|
},300);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
onDoubleClick() {
|
||||||
|
clearTimeout(this.doubleClickFlag);
|
||||||
|
this.props.root.onDoubleClick(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
onMouseEnter(e) {
|
onMouseEnter(e) {
|
||||||
|
@ -316,6 +331,10 @@ class TreeNode extends React.Component {
|
||||||
// }
|
// }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if(props.onDoubleClick){
|
||||||
|
domProps.onDoubleClick = this.onDoubleClick;
|
||||||
|
}
|
||||||
|
|
||||||
if (props.onRightClick) {
|
if (props.onRightClick) {
|
||||||
domProps.onContextMenu = this.onContextMenu;
|
domProps.onContextMenu = this.onContextMenu;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue