每次可以允许多个按钮被按下,例如:"按钮二",第一次单击是按下,第二次单击是松开
此时allowMultiple:false用户按下按钮的顺序为:"按钮一","按钮二","按钮三","按钮三","按钮二","按钮一",注意观察控制台的显示
每次只允许一个按钮被按下
______________________________________________________________________________
launch: function() {
//
var segmentedButton=Ext.create('Ext.SegmentedButton',{
//allowMultiple:为true,允许同事将多个按钮设置为按下状态.为false:最多允许有一个按钮处于按下状态
allowMultiple:false,//
items:[
{
text:'按钮一'
},{
text:'按钮二'
},{
text:'按钮三'
}
],
listeners:{
//toggle:触发器.当按钮的状态发生改变时,触发该事件.有三个参数,container:代表segmentedButton组件本身,button:发生状态改变的按钮,pressed:布尔值,true:按钮被按下的状态,false:按钮被松开的状态
toggle:function(container,button,pressed){
if(pressed){
console.log('用户按下了'+button.getText()+'按钮');
}else{
console.log('用户松开了'+button.getText()+'按钮');
}
}
}
});
var myToolBar=Ext.create('Ext.Toolbar',{
id:'mytoolBar',
docked:'top',//按钮停靠的位置,可选项为top,bottom,left,right.默认是top
items:[
segmentedButton
]
});
![segmentedButton按钮一:基本示例](http://img.413yy.cn/images/31101031/31105336t0102a17172135cd9b0.jpg)
var myPanel=Ext.create('Ext.Panel',{
id:'myPanel',
items:[
myToolBar
],
html:'测试数据'
});
Ext.Viewport.add(myPanel);
},
______________________________________________________________________________