• 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: Help on NSToolbar
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Help on NSToolbar


  • Subject: Re: Help on NSToolbar
  • From: Mike Abdullah <email@hidden>
  • Date: Wed, 15 Mar 2006 19:23:06 +0000


On 15 Mar 2006, at 01:40, Karim Morsy wrote:

thanks a lot for the help, mike!

In your NIB file, you already have an NSWindow. Now for each preference, you want to add an NSView to the NIB. If you want more help on this, just e-mail me off list.

ok, I've added 6 views to the nib file and connected the outlets of file's owner (prefs controller) with them. the nib file also contains a single prefs window with blank content and a toolbar that's created in awake from nib.


Now whenever the user clicks on an item in the toolbar, you need to do something like:

[MyWindow setContentView: nil];

do i really have to set the content view to nil ? because if I do that the content of the window turns black for like a tenth of a second.

You don't have to set the content to nil (and I assume you mean the window turns blank, not black? because I've never had it turn black). I do this for aesthetic reasons. Remove the content, resize, place the new content. But it's up to you.

[MyWindow setFrame: [newPreferenceView frame] display: YES animate: YES];

[MyWindow setContentView: newPreferenceView];

if I do this the window does not resize correctly. if I press an item multiple times the window gets smaller and smaller and the origin is in the wrong location.
i tried to resize and relocate like this:
int diff= [window frame].size.height - [prefsView frame].size.height;
newFrame.size.height += diff; // hoehenveränderung
newFrame.origin.y -= diff;
[window setFrame: newFrame display: YES animate: YES];
[window setContentView: prefsView];


however, this doesn't result exactly in the desired bahavior of the window.

Yes, sorry I messed up slightly here. It's because I've been doing some similar stuff, but different recently!


What you want to do is calculate the height difference between the old content view and the new content view. Then adjust the windows frame by this amount. Something like:

float heightChange = [newPrefsView frame].size.height - [[window contentView] frame].size.height

NSRect newWindowFrame = [window frame];
newWindowFrame.size.height += heightChange;
newWindowFrame.origin.y -= heightChange;
[window setFrame: newWindowFrame display: YES animate: YES];

[window setContentView: newPrefsView];


any further help on this topic would be highly appreciated.

Thanks again,
Karim


Enjoy!

Mike.




On Mar 12, 2006, at 8:47 PM, Mike Abdullah wrote:

No problem.

In your NIB file, you already have an NSWindow. Now for each preference, you want to add an NSView to the NIB. If you want more help on this, just e-mail me off list.

Now whenever the user clicks on an item in the toolbar, you need to do something like:

[MyWindow setContentView: nil];

[MyWindow setFrame: [newPreferenceView frame] display: YES animate: YES];

[MyWindow setContentView: newPreferenceView];

Hope that helps.

Mike.

On 12 Mar 2006, at 19:06, Karim Morsy wrote:


_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >Help on NSToolbar (From: Karim Morsy <email@hidden>)
 >Re: Help on NSToolbar (From: Uli Kusterer <email@hidden>)
 >Re: Help on NSToolbar (From: Karim Morsy <email@hidden>)
 >Re: Help on NSToolbar (From: Mike Abdullah <email@hidden>)
 >Re: Help on NSToolbar (From: Karim Morsy <email@hidden>)
 >Re: Help on NSToolbar (From: Mike Abdullah <email@hidden>)
 >Re: Help on NSToolbar (From: Karim Morsy <email@hidden>)

  • Prev by Date: Re: Parsing a string into a NSDate
  • Next by Date: Documentation clarification - NSPredicate LIKE operator?
  • Previous by thread: Re: Help on NSToolbar
  • Next by thread: Re: Help on NSToolbar
  • Index(es):
    • Date
    • Thread