Jacobian
Jacobian

Reputation: 10802

How to catch Delete key event in tree panel controller

I have a tree panel view (defined as FilesEditorNavigTree) and a controller. In a controller I want to catch Delete key event in order to perform some procedure. I tried to do it like this:

...
init:function(){
    this.control({
        'FilesEditorNavigTree':{
             specialkey:function(a, b){
                 alert(b.keyCode); // just for testing reasons
             }

But it has no effect.

Upvotes: 1

Views: 392

Answers (1)

Guilherme Lopes
Guilherme Lopes

Reputation: 4760

Use the rowkeydown listener of the treepanel view.

Ext.create('Ext.tree.Panel', {
    title: 'Simple Tree',
    width: 200,
    height: 150,
    store: store,
    rootVisible: false,
    renderTo: Ext.getBody(),
    listeners : {
        rowkeydown : function(view, record, tr, rowIndex, e) {
            if (e.keyCode === 46) { 
                console.log('hit delete');
            }
        }
    }
});

Upvotes: 1

Related Questions