PDA

View Full Version : SegmentedButton allowDepress clarification



nm1
19 Sep 2012, 1:42 AM
I came across several hits for this topic in the forums, but I am clear what allowDepress implies. I just want to confirm my comment below is correct -

1. Clicking an unpressed button, switches it to pressed state.
2. If allowDepress=false, then you cannot unpress a pressed button. The only way to unpress a button is by pressing another button in the SegmentedButton set.

This gives me a radio button like functionality where only a single button is pressed.

I wrote a simple example where I set allowDepress=false, but I observed while single stepping thru the code, the updateAllowMultiple method switches this to true because this.getInitialConfig().hasOwnProperty('allowDepress') returns false. Is this a known bug?

mitchellsimoens
21 Sep 2012, 4:17 AM
This is correct behavior. If you have allowMultiple set to true but if you have allowDepress set to false, how would you get a button depressed?

nm1
21 Sep 2012, 6:00 AM
I have not specified allowMultiple, which I assume means its false.

Is this a bug?

mitchellsimoens
21 Sep 2012, 6:55 AM
By default, allowDepress and allowMultiple is set to false meaning you can only have 1 button pressed at one time. After the initial button press, you will no longer be able to have no buttons pressed. This example allows for only one button pressed at one time:


Ext.Viewport.add({
items : [
{
xtype : 'segmentedbutton',
items : [
{
text : 'One'
},
{
text : 'Two'
},
{
text : 'Three'
}
]
}
]
});