Skip to content

Instantly share code, notes, and snippets.

@geecu
Created June 11, 2010 13:28
Show Gist options
  • Save geecu/434467 to your computer and use it in GitHub Desktop.
Save geecu/434467 to your computer and use it in GitHub Desktop.
function dbg(o)
{
Ti.API.info(o);
}
var win = Ti.UI.createWindow({backgroundColor: '#444'});
var btnProperties = {
backgroundImage: 'enabled.png',
backgroundDisabledImage: 'disabled.png',
width: 70,
height: 13,
};
var btn1 = Ti.UI.createButton(btnProperties);
var btn2 = Ti.UI.createButton(btnProperties);
var controlBtn = Ti.UI.createButton(
{
title: 'Toggle',
width: 100,
height: 30,
top: 10
});
controlBtn.addEventListener('click', function()
{
try
{
dbg('toggling');
dbg('is enabled '+btn1.enabled);
btn1.enabled = !btn1.enabled;
btn2.enabled = !btn2.enabled;
dbg('became enabled '+btn1.enabled);
win.setToolbar(null, {animated: false});
setTimeout(function()
{
dbg('setting toolbar');
win.setToolbar([btn1], {animated: false});
dbg('set toolbar');
}, 1000);
}
catch (err)
{
dbg('[ERROR!!!]'+err.message);
}
});
win.add(controlBtn);
//win.open();
win.add(btn2);
win.setToolbar([btn1]);
var tabGroup = Titanium.UI.createTabGroup();
var tab = Titanium.UI.createTab(
{
title: 'Test tab',
window: win
});
tabGroup.addTab(tab);
tabGroup.open();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment