1. #1
    Ext JS Premium Member
    Join Date
    Mar 2011
    Posts
    69
    Vote Rating
    0
    scancubus is on a distinguished road

      0  

    Default Button Toggle Group click event being fired when allowDepress:false

    Button Toggle Group click event being fired when allowDepress:false


    Hello,
    I am glad that you added a config for "allowDepress" with a button toggle group. However, if you set it to false, I don't think that the buttons "click" event should be fired. If it is a valid toggle, it makes sense to fire, otherwise, do not fire the event. Thoughts?

    Code:
     {
    				xtype : 'button',
    				allowDepress:false,
    				text : 'Range',
    				enableToggle:true,
    				toggleGroup : 'myToggleGroup',
    				pressed : true,
    				listeners:{
    					click:function(){
                                                      Ext.log('button click event fired on Range');
    					},
    					scope:this
    				}
    			}, {
    				xtype : 'button',
    				allowDepress:false,
    				text : 'Specific',
    				enableToggle:true,
    				toggleGroup : 'myToggleGroup',
    				listeners:{
    					click:function(){
    						Ext.log('button click event fired on Specific');
    					},
    					scope:this
    				}
    			}
    Please notice that the log shows the click event has been fired when the button is already pressed.
    Thanks.

  2. #2
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    16,120
    Vote Rating
    508
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    That behaviour is expected. Regardless of the pressed state, you're still clicking the button. If you only want to listen for when the button is toggled, use the toggleHandler:

    Code:
    Ext.onReady(function() {
        
        var makeButton = function(num, pressed){
            Ext.create('Ext.button.Button', {
                renderTo: document.body,
                text: 'B' + num,
                pressed: pressed,
                toggleGroup: 'group',
                allowDepress: false,
                handler: function(btn){
                    console.log('handler', btn.text);
                },
                toggleHandler: function(btn, pressed){
                    console.log('toggle', btn.text, pressed);
                }
            });
        };
    
        for (var i = 1; i <= 5; ++i) {
            makeButton(i, i === 3);
        }
        
    });
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

Thread Participants: 1

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar