PDA

View Full Version : [FIXED] Segmented Button ignores pressed true when ...



keckeroo
30 Aug 2011, 8:58 PM
one of the buttons in the items is disabled.



this.folderButtons = new Ext.SegmentedButton({
items: [
{ text: 'Inbox', pressed: true },
{ text: 'Sent' },
{ text: 'Saved', disabled: true },
{ text: 'Trash' }
]
});


In this example - 'Inbox' is not pressed. However - if i remove the ", disabled: true" from the Saved button, Inbox renders as pressed.

mike.estes
31 Aug 2011, 12:31 PM
I've confirmed the issue and have put in a bug report. I have an override that seems to fix the problem in my own testing, would you mind testing it out in your app?



Ext.override(Ext.SegmentedButton, {
onTap : function(e, t) {
if (!this.disabled && (t = e.getTarget('.x-button'))) {
var c = Ext.getCmp(t.id);
if (c && !c.disabled) {
this.setPressed(t.id, this.allowDepress ? undefined : true);
}
}
},
afterLayout : function(layout) {
var me = this;


Ext.SegmentedButton.superclass.afterLayout.call(me, layout);


if (!me.initialized) {
me.items.each(function(item, index) {
if (!item.disabled) {
me.setPressed(item, !!item.pressed, true);
}
});
if (me.allowMultiple) {
me.pressedButtons = me.getPressedButtons();
}
me.initialized = true;
}
}
});

keckeroo
31 Aug 2011, 6:54 PM
Yay - I found a bug! Yay - I got a patch! Yay - it works! :-)

Thank you!

Kev