feat 增加keyDown钩子函数keyFun

This commit is contained in:
izbz wh 2019-04-18 16:34:25 +08:00
parent f18d420e91
commit e12427aa01
7 changed files with 166 additions and 153 deletions

View File

@ -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

3
dist/demo.css vendored

File diff suppressed because one or more lines are too long

2
dist/demo.css.map vendored

File diff suppressed because one or more lines are too long

298
dist/demo.js vendored

File diff suppressed because one or more lines are too long

2
dist/demo.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -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){