分段按钮值to setPressed不起作用

时间:2012-06-28 04:04:42

标签: sencha-touch-2 uisegmentedcontrol

我正在创建一个分段按钮,我需要根据分段按钮的值修改应用。

{

                    margin : '5 -5 0 25',
                    xtype: 'segmentedbutton',
                    allowMultiple: true,
                    height : 40,
                    id : 'fontStyleBtn',
                    items: [
                            {
                                text: 'B',
                                width : 50,
                                style: 'background-color:red !important',
                                action : 'boldText'
                            },
                        {
                            text: 'I',
                            width : 50,
                            style: 'font-size:14px;font-style:italic;background-color:#008c99',
                            action : 'italicText'
                        },
                        {
                            text: 'U',
                            width : 50,
                            style: 'font-size:14px;background-color:#008c99;text-decoration:underline',
                            action : 'underlineText'
                        }
                    ]}

当我点按B时,我的应用中的文字变得粗体。但我需要为它设置一个值,以便下次点击它时,我可以将文本重置为正常。

Ext.getCmp('fontStyleBtn').getItems()[0].pressed = true;

这似乎对我不起作用。

1 个答案:

答案 0 :(得分:0)

Ext.getCmp('fontStyleBtn').getItems()[0]是否完全返回“B”按钮?

如果是,请改为尝试:

Ext.getCmp('fontStyleBtn').getItems()[0].setPressed(true);

相关问题