Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

TabView add item - labels/tabs not displayed

#10

cant get addTabViewItem:item to function, throws Uncaught TypeError: Cannot read property '_superview' of null

Reported by TG · September 4th, 2008 @ 08:33 PM

State: open
Milestone: none
Assigned to: nobody

Activity

  1. Francisco Tolmasky
    Francisco Tolmasky

    Could you show me the code snippet?

    September 4th, 2008 @ 08:38 PM

  2. TG
    TG

    var tabset=[[CPTabView alloc] initWithFrame:CPRectMake(10,10,300,300)];

    var item1=[[CPTabViewItem alloc] initWithIdentifier:@"0"];
    [item1 setLabel:@"test"];
    [tabset addTabViewItem:item1];
    var item2=[[CPTabViewItem alloc] initWithIdentifier:@"1"];
    [item2 setLabel:@"test2"];
    [tabset addTabViewItem:item2];
    
    

    [label setStringValue:[[tabset numberOfTabViewItems] stringValue]];

    [contentView addSubview:tabset];
    [contentView addSubview:label];
    
    

    September 4th, 2008 @ 08:54 PM

  3. TG
    TG

    var tabset=[[CPTabView alloc] initWithFrame:CPRectMake(10,10,300,300)];

    var item1=[[CPTabViewItem alloc] initWithIdentifier:@"0"];
    [item1 setLabel:@"test"];
    [tabset addTabViewItem:item1];
    var item2=[[CPTabViewItem alloc] initWithIdentifier:@"1"];
    [item2 setLabel:@"test2"];
    [tabset addTabViewItem:item2];
    
    

    [label setStringValue:[[tabset numberOfTabViewItems] stringValue]];

    [contentView addSubview:tabset];
    [contentView addSubview:label];
    
    

    -----Original Message----- From: Lighthouse [mailto:support@lighthouseapp.com] Sent: Thursday, September 04, 2008 11:41 PM To: Tom Giannulli Subject: [Cappuccino #10 TabView add item - labels/tabs not displayed] TabView add item

    September 4th, 2008 @ 08:55 PM

  4. Francisco Tolmasky
    Francisco Tolmasky

    Ah yes it's because the tab view item doesn't have an associated view ([item setView:myView]). I will check whether the expected behavior should be to raise an internsalinconsistencyexception or to just show nothing in the tabview.

    For right now though, if you just do [item setView:[[CPView alloc] initWithFrame:CGRectMakeZero()]]] it should work though.

    September 4th, 2008 @ 09:00 PM

  5. TG
    TG
    • Tag set to appkit, nullvalueexception

    The error is solved but the tabs/labels are not displayed

    September 4th, 2008 @ 09:12 PM

  6. TG
    TG
    • Title changed from TabView add item to TabView add item - labels/tabs not displayed

    var tabset=[[CPTabView alloc] initWithFrame:CPRectMake(10,10,300,300)];

    var x=@"tab1";
    var y=@"tab2";
    var item1=[[CPTabViewItem alloc] initWithIdentifier:x];
    [item1 setLabel:@"test1"];
    [item1 setView:[[CPView alloc] initWithFrame:CPRectMake(0,0,0,0)]];
    [tabset addTabViewItem:item1];
    var item2=[[CPTabViewItem alloc] initWithIdentifier:y];
    [item2 setLabel:@"test2"];
    [item2 setView:[[CPView alloc] initWithFrame:CPRectMake(0,0,200,200)]];
    [tabset addTabViewItem:item2];
    
    [tabset setTabViewType:CPTopTabsBezelBorder];
    [label setStringValue:[[tabset numberOfTabViewItems] stringValue]];
    [contentView addSubview:tabset];
    
    

    September 10th, 2008 @ 07:07 AM

  7. Will Larson
    Will Larson

    I confirm this as well. To be on the safe side I checked on Safari and FireFox, and neither display anything. I looked through the source a bit, and couldn't find any trickery to force it to display the labels.

    September 11th, 2008 @ 05:46 AM

  8. Francisco Tolmasky
    Francisco Tolmasky

    Could you try setting the tabViewType earlier, like right after you create the tab view itself. Not that this wouldn't be a bug, just trying to identify where the problem is.

    September 11th, 2008 @ 06:00 AM

  9. Will Larson
    Will Larson

    Tried your suggestion, but isn't working for me. Here is my source:

    
    
    -(void)setupTabView: (CPView)contentView {
      var bounds = [contentView bounds];
      var frame = CGRectMake(CGRectGetMinX(bounds)+75,
    			 CGRectGetMinY(bounds)+100,
    			 CGRectGetWidth(bounds)-150,
    			 CGRectGetHeight(bounds)-200);
      tabView = [[CPTabView alloc] initWithFrame:frame];
      [tabView setTabViewType:CPTopTabsBezelBorder];
      [tabView layoutSubviews];
      [tabView setAutoresizingMask: CPViewHeightSizable | CPViewWidthSizable];
    
    
      webSearchTabItem = [[CPTabViewItem alloc] initWithIdentifier:@"web"];
      imageSearchTabItem = [[CPTabViewItem alloc] initWithIdentifier:@"image"];
      newsSearchTabItem = [[CPTabViewItem alloc] initWithIdentifier:@"news"];
    
      webView = [[CPView alloc] initWithFrame:CPRectMakeZero()];
      imageView = [[CPView alloc] initWithFrame:CPRectMakeZero()];
      newsView = [[CPView alloc] initWithFrame:CPRectMakeZero()];
    
      [webSearchTabItem setLabel:@"Web"];
      [imageSearchTabItem setLabel:@"Image"];
      [newsSearchTabItem setLabel:@"News"];
    
      [webSearchTabItem setView:webView];
      [imageSearchTabItem setView:imageView];
      [newsSearchTabItem setView:newsView];
    
      [tabView addTabViewItem:webSearchTabItem];
      [tabView addTabViewItem:imageSearchTabItem];
      [tabView addTabViewItem:newsSearchTabItem];
    
    
      //[tabView _createBezelBorder];
      [contentView addSubview:tabView];
    }
    
    

    September 11th, 2008 @ 06:05 AM

  10. Will Larson
    Will Larson

    Sorry for formatting: http://dpaste.com/77487/ is formatted paste.

    September 11th, 2008 @ 06:06 AM

  11. Will Larson
    Will Larson

    I've been able to narrow down the issue (and find a work around): if you add the tabView to its parent view before adding the tab items, then it works correctly (creates labels and displays the tabViewItem's view when the tab is selected).

    However, if you add the tabViewItems before adding the tabView to the parentView, then it neither creates the labels nor displays the tabViewItem's view as appropriate.

    September 11th, 2008 @ 07:32 AM

  12. Francisco Tolmasky
    Francisco Tolmasky

    Great reduction WIll, I think I should have a fix for this soon.

    September 11th, 2008 @ 08:52 AM

  13. Francisco Tolmasky
  14. Ross Boucher
    Ross Boucher
    • State changed from new to open
    • Tag changed from appkit, nullvalueexception to appkit, nullvalueexception
    • Milestone cleared.

    The issue here is that we delay creating the tab view borders and items as long as possible, so that we prevent unnecessarily loading images that we may not need.

    As a side effect, there's a view we haven't created yet, and we're just sending messages to nil. This is why it's not working. There's also a related bug with trying to change a view out from under it later.

    Essentially, the way this all works needs to be redesigned to work more like the menu system. Since it isn't a trivial change, I'm moving it off 0.5.2. I'm also not planning on committing a stop gap measure, since the workaround is noted above. Just add items after adding the tab view to your content view.

    September 18th, 2008 @ 07:43 PM

  15. ronin-756 (at lighthouseapp)
    ronin-756 (at lighthouseapp)
    • Tag changed from appkit, nullvalueexception to @acknowledged, appkit, nullvalueexception

    I've been able to reproduce this in 0.7b. Here is the sample code : http://gist.github.com/83994

    March 23rd, 2009 @ 10:09 PM

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.