feat 增加keyDown钩子函数keyFun
This commit is contained in:
parent
f18d420e91
commit
e12427aa01
|
@ -71,6 +71,11 @@ class Demo2 extends Component{
|
|||
console.log('onSelect', info);
|
||||
this.setState({ selectedKeys });
|
||||
}
|
||||
// keydown的钩子事件
|
||||
onKeyDown = (e,treeNode)=>{
|
||||
console.log('***',e);
|
||||
return false;
|
||||
}
|
||||
render() {
|
||||
const loop = data => data.map((item) => {
|
||||
if (item.children) {
|
||||
|
@ -91,6 +96,7 @@ class Demo2 extends Component{
|
|||
autoExpandParent={this.state.autoExpandParent}
|
||||
onCheck={this.onCheck}
|
||||
onSelect={this.onSelect}
|
||||
keyFun={this.onKeyDown}
|
||||
>
|
||||
{loop(gData)}
|
||||
</Tree>
|
||||
|
|
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
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -512,7 +512,8 @@ onExpand(treeNode,keyType) {
|
|||
}
|
||||
// all keyboard events callbacks run from here at first
|
||||
onKeyDown(e,treeNode) {
|
||||
e.stopPropagation();
|
||||
// e.stopPropagation();
|
||||
|
||||
const props = this.props;
|
||||
const currentPos = treeNode.props.pos;
|
||||
const currentIndex = currentPos.substr(currentPos.lastIndexOf('-')+1);
|
||||
|
@ -533,8 +534,9 @@ onExpand(treeNode,keyType) {
|
|||
}else if(e.keyCode == KeyCode.ENTER){
|
||||
this.onDoubleClick(treeNode);
|
||||
}
|
||||
this.props.keyFun && this.props.keyFun(e,treeNode);
|
||||
// e.preventDefault();
|
||||
|
||||
|
||||
}
|
||||
|
||||
_focusDom(selectKeyDomPos,targetDom){
|
||||
|
|
Loading…
Reference in New Issue