#10 open
TG

TabView add item - labels/tabs not displayed

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

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

Comments and changes to this ticket

  • Francisco Tolmasky

    Francisco Tolmasky September 4th, 2008 @ 08:38 PM

    Could you show me the code snippet?

  • TG

    TG September 4th, 2008 @ 08:54 PM

    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];
    
    
  • TG

    TG September 4th, 2008 @ 08:55 PM

    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

  • Francisco Tolmasky

    Francisco Tolmasky September 4th, 2008 @ 09:00 PM

    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.

  • TG

    TG September 4th, 2008 @ 09:12 PM

    • Tag set to appkit, nullvalueexception

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

  • TG

    TG September 10th, 2008 @ 07:07 AM

    • 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];
    
    
  • Will Larson

    Will Larson September 11th, 2008 @ 05:46 AM

    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.

  • Francisco Tolmasky

    Francisco Tolmasky September 11th, 2008 @ 06:00 AM

    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.

  • Will Larson

    Will Larson September 11th, 2008 @ 06:05 AM

    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];
    }
    
    
  • Will Larson

    Will Larson September 11th, 2008 @ 06:06 AM

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

  • Will Larson

    Will Larson September 11th, 2008 @ 07:32 AM

    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.

  • Francisco Tolmasky

    Francisco Tolmasky September 11th, 2008 @ 08:52 AM

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

  • Francisco Tolmasky
  • Ross Boucher

    Ross Boucher September 18th, 2008 @ 07:43 PM

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

  • ronin-756 (at lighthouseapp)

    ronin-756 (at lighthouseapp) March 23rd, 2009 @ 10:09 PM

    • 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

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.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

The Cappuccino Web Framework, including AppKit, Foundation, and Objective-J.

Shared Ticket Bins

People watching this ticket

Referenced by

Pages