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,828
    Vote Rating
    609
    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

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi