• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Tabs window autoresizing.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Tabs window autoresizing.


  • Subject: Re: Tabs window autoresizing.
  • From: Antonio Carusone <email@hidden>
  • Date: Mon, 9 Feb 2004 15:15:16 -0500

Thanks Ryan. Ill try that out.

Antonio


On Feb 9, 2004, at 3:02 PM, Ryan Bates wrote:

On Feb 9, 2004, at 10:55 AM, Antonio Carusone wrote:
The problem is that im really new to all this on some of what you wrote doesnt make sense to me. Do you know if theres some kind of tutorial for this?

If you have access to ADC TV then there is a session on there explaining it. Other then that I don't know of any other tutorials, but here's a little more detailed explenation:

First you need to set up a delegate for the NSTabView. Creating delegates is a fairly common practice in Cocoa programming. You can do this by connecting the "delegate" outlet to one of your custom object instances using Interface Builder. NSTabView will send a message to its delegate when a user clicks on a tab. Like this:

// NSTabView calls this upon user clicking tab
[delegate tabView:self didSelectTabViewItem:tabItem];

This means, if the "delegate" object has a method called "tabView:didSelectTabViewItem:" then that method will be called. You can perform any action in this method, including changing the size of the window. Here's a basic way you would implement the method:

// in NSTabView's Delegate Object
- (void)tabView:(NSTabView *)tabView didSelectTabViewItem:(NSTabViewItem *)tabViewItem
{
NSRect frame;
int height;

// Determine the height of the window based upon the selected tab
// The identifier is a usually a string defined for each
// tab through the Interface Builder info panel
if ([[tabViewItem identifier] isEqualTo:@"tabItem1"]) {
height = 400;

} else if ([[tabViewItem identifier] isEqualTo:@"tabItem2"]) {
height = 300;

} // etc...

// We now need to establish the new window frame.
// First grab the current window frame and we will
// adjust that.
frame = [[tabView window] frame];

// The "origin" of the frame is the bottom left corner
// So we will need to change that along with the height
// If we did not change the origin the window would
// animate up rather than down. Try both ways.
frame.size.height = height;
frame.origin.y += height;

// Now set the new window frame and animate it.
[[tabView window] setFrame:frame display:YES animate:YES]
}

Note: There is another delegate method called "tabView:willSelectTabViewItem:" which may be the correct one to use. Try both.

I haven't tested this code, so let me know if you get any errors.

Ryan
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: Tabs window autoresizing. (From: Ryan Bates <email@hidden>)

  • Prev by Date: Re: Tabs window autoresizing.
  • Next by Date: Re: catching uncaught exceptions
  • Previous by thread: Re: Tabs window autoresizing.
  • Next by thread: Tabs strange behavior...
  • Index(es):
    • Date
    • Thread