Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add Click Event with ExtJS Panel

Tags:

extjs

I am trying to create panel in ext js and got success on that but I also want to add click event with this

       {
            xtype: 'panel',
            flex: 1,
            x: 10,
            y: parseInt(panelCreation[i - 1].y) + 
               parseInt(panelCreation[i -1].height) + 10,
            width: twidth,
            height: theight,
            layout: 'absolute'                
        }

I don't want to add click event separately I want to add with this code like after layout:absolute add comma and event please help me in this.

like image 408
Asif Khan Avatar asked Feb 24 '11 17:02

Asif Khan


1 Answers

You can add in the following for a click event:

listeners: {
   'render': function(panel) {
       panel.body.on('click', function() {
           alert('onclick');
       });
    }
}

EDIT: to get the X and Y coordinates of the click event you can change the click event handler as follows...

panel.body.on('click', function(e) {
   alert('X: ' + e.getPageX());
   alert('Y: ' + e.getPageY());
});
like image 84
JamesHalsall Avatar answered Dec 11 '22 08:12

JamesHalsall