Problem
Developers should be prevented from adding children to widgets, but it is currently possible on iOS.
Android exhibits the correct behavior.
Test case
var win1 = Titanium.UI.createWindow({
title:'Window 1',
backgroundColor:'#fff'
});
var moreBtn = Titanium.UI.createButton({
bottom:25,
borderRadius:5,
height:40,
width:120
});
var buttonLabel = Ti.UI.createLabel({
backgroundColor:'transparent',
text: 'Find Out More',
color: '#000',
textAlign:'center',
width: 'auto',
height:'auto'
});
moreBtn.add(buttonLabel);
win1.add(moreBtn);
win1.open();
moreBtn.addEventListener('click', function(){
Ti.Platform.openURL('http://www.google.com');
});
Currently, Android does not allow children to be added to random controls. It adds an extra depth layer to the view hierarchy and the depth can only be 12-14 depending on the OS rev and vendor.
Workaround, put the controls in a view.
Jeff's latest documentation confirms that this ticket is invalid:
"Widgets are simply special types of Views that have special functionality such as Buttons and Textfields. Underneath the cover a Widget is a View. However, unlike typical Views, Widgets cannot themselves have children."
After some thought, this is an inconsistency issue between the documentation (correct behaviour) and the KS. See https://github.com/appcelerator/titanium_mobile/blob/master/demos/KitchenSink/Resources/examples/button.js#L41"> button.js.
Hence, the KS needs to be corrected. Will seek Don's advice on how to proceed.
Raised TIMOB-7350 to correct KS.
Tested on the iOS simulator using TiSDK 2.2.0v20120821095711, issue still valid.
Closing ticket as invalid as this version of Kitchen Sink is no longer in use.
Resolving ticket as Invalid as there is now a new version of Kitchen Sink available and we no longer support the version which relates to this ticket.