Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mousedown / mouseup events on ExtJS 4 buttons

I'm trying to make a button fire the mousedown and mouseup events on ExtJS 4, but I cannot find a properly way to do this.

I was trying to do something like this on my controller:

init: function()
{
    this.control(
    {
       'button[itemId="pttButton"]': 
       {
          mousedown: doSomething,
          mouseUp:   doSomethingElse
       }
    });
}

but these events don't seem to exist.

What's the best way to do this other than access directly the dom and using native Javascript events?

like image 733
MastErAldo Avatar asked Oct 20 '25 06:10

MastErAldo


1 Answers

Because button does not have mousedown and mouseup events, easiest way is to add listeners for this events on the button component's element. Element which representing component you can get by component's getEl() method.

    var btn = Ext.create('Ext.Button', {
        text: 'Click me',
        renderTo: Ext.getBody()

    });

    btn.mon(btn.getEl(), {
        mousedown: function() {
            console.log('down');
        },
        mouseup: function() {
            console.log('up');
        }
    });
like image 91
Akatum Avatar answered Oct 21 '25 21:10

Akatum



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!