Toggle Button

  source

Ext.define("Extras.buttons.ToggleButton",{
    extend:"Ext.Button",
    xtype:'togglebtn',
    config:{
        isPressed:false
    },
    initialize:function() {
        this.callParent( arguments );
        this.on("tap", this.onButtonPress, this);
        this.getIsPressed() ? this.addCls( this.getPressedCls() ) : this.removeCls( this.getPressedCls() );
        this.setText( this.getIsPressed() ? 'pressed' : 'not pressed');
    },
    
    onButtonPress:function() {
        this.setIsPressed( ! this.getIsPressed() );
        this.getIsPressed() ? this.addCls( this.getPressedCls() ) : this.removeCls( this.getPressedCls() );
        this.setText( this.getIsPressed() ? 'pressed' : 'not pressed');
    }
    
});