ButtonBar ignores enabled property on labels
Here's a quick demo - am I missing something? mobilesdk 1.2.0
var win = Titanium.UI.createWindow({
backgroundColor:'#fff',
barColor: '#660000',
tabBarHidden:true
});
// create tab group to manage multiple windows
var tabGroup = Titanium.UI.createTabGroup();
var tab = Titanium.UI.createTab({
title:'Bug Demo',
window:win
});
tabGroup.addTab(tab);
tabGroup.open();
var tc = Ti.UI.createButtonBar({
labels: [{
title: 'disabled',
enabled: false
},{
title: 'enabled',
enabled: true
}],
backgroundColor: '#660000'
});
win.rightNavButton = tc;
Update: it turns out that setting the style of the buttonbar to Ti.UI.iPhone.SystemButtonStyle.BAR is what makes this work. So I guess it's iPhone only (of course, the buttonbar usually lives in the iPhone-only title bar or iPhone-only Toolbar, so maybe it's OK that way).
Thanks for giving me a working example to compare to, Clint.
1 Answer
-
Accepted Answer
this works:
var buttons = [ {title:'Disabled', width:100, enabled:false}, {title:'Enabled', width:100, enabled:true} ]; var buttonBar = Titanium.UI.createButtonBar({ labels:buttons, backgroundColor:'#000', top:50, left:120, style:Titanium.UI.iPhone.SystemButtonStyle.BAR, height:40 }); buttonBar.addEventListener('click', function(e) { Ti.API.log(e.index); // toggle button bar style if (e.index == 1) { buttons[0].enabled = (buttons[0].enabled==false)?true:false; buttonBar.labels = buttons; } Ti.API.log('You clicked index = ' + e.index); }); win.rightNavButton = buttonBar;
seems that for the properties to be recognized they need to be defined in an external array and then assign the labels array to the other array..