Open tbalthazar opened 15 years ago
TabView add item
Could you show me the code snippet?
by Francisco Tolmasky
TabView add item
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];
by TG
TabView add item
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
by TG
TabView add item
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.
by Francisco Tolmasky
TabView add item
The error is solved but the tabs/labels are not displayed
by TG
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];
by TG
TabView add item - labels/tabs not displayed
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.
by Will Larson
TabView add item - labels/tabs not displayed
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.
by Francisco Tolmasky
TabView add item - labels/tabs not displayed
Tried your suggestion, but isn’t working for me. Here is my source:
@@@ javascript
-(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]; }
@@@
by Will Larson
TabView add item - labels/tabs not displayed
Sorry for formatting: http://dpaste.com/77487/ is formatted paste.
by Will Larson
TabView add item - labels/tabs not displayed
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.
by Will Larson
TabView add item - labels/tabs not displayed
Great reduction WIll, I think I should have a fix for this soon.
by Francisco Tolmasky
TabView add item - labels/tabs not displayed
by Francisco Tolmasky
TabView add item - labels/tabs not displayed
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.
by Ross Boucher
TabView add item - labels/tabs not displayed
I’ve been able to reproduce this in 0.7b. Here is the sample code : http://gist.github.com/83994
by Thomas Balthazar
cant get addTabViewItem:item to function, throws Uncaught TypeError: Cannot read property ’_superview’ of null
original LH ticket
This ticket has 0 attachment(s).