Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-2325] iOS: prevent add child to widget (ie. label added to button)

GitHub Issuen/a
TypeBug
PriorityLow
StatusClosed
ResolutionInvalid
Resolution Date2017-04-28T20:52:02.000+0000
Affected Version/sRelease 3.0.0
Fix Version/sn/a
ComponentsiOS
Labelscore
ReporterPaul Dowsett
AssigneeIngo Muschenetz
Created2011-04-15T03:16:45.000+0000
Updated2017-05-02T21:32:23.000+0000

Description

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');
});

Comments

  1. Don Thorp 2011-04-15

    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.

  2. hal 2011-04-15

    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."

  3. hal 2011-04-15

    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.

  4. Paul Dowsett 2012-01-24

    Raised TIMOB-7350 to correct KS.
  5. Junaid Younus 2012-08-23

    Tested on the iOS simulator using TiSDK 2.2.0v20120821095711, issue still valid.
  6. Lee Morris 2017-04-28

    Closing ticket as invalid as this version of Kitchen Sink is no longer in use.
  7. Lee Morris 2017-05-02

    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.

JSON Source