inane
inane

Reputation: 648

How to get the button pressed on a segmentedButton in Sencha

I am newbie in Sencha Touch and I have a "segmentedButton" component, and I need to get the button pressed depending the user interaction in the controller.

Help please!!

Upvotes: 2

Views: 4716

Answers (2)

Ravi MCA
Ravi MCA

Reputation: 2631

If anyone is looking for the same for Ext Classic here is the solution.

To get the values use container.getValue().

To set the values use container.setValue().

Fiddle is here

Upvotes: 0

Guilherme Lopes
Guilherme Lopes

Reputation: 4760

You can use the getPressedButtons() method.

Example:

Ext.application({
    name : 'Fiddle',

    launch : function() {
        var segmentedButton = Ext.create('Ext.SegmentedButton', {
            allowMultiple: true,
            items: [{
                text: 'Option 1'
            },{
                text: 'Option 2',
                pressed: true
            },{
                text: 'Option 3'
            }],
            listeners: {
                toggle: function(container, button, pressed){
                    alert("User toggled the '" + button.getText() + "' button: " + (pressed ? 'on' : 'off'));
                    console.log(container.getPressedButtons());
                }
            }
        });
        Ext.Viewport.add({ xtype: 'container', padding: 10, items: [segmentedButton] });
    }
});

Upvotes: 4

Related Questions