Re: Cocoa Document-Based Application
Re: Cocoa Document-Based Application
- Subject: Re: Cocoa Document-Based Application
- From: PGM <email@hidden>
- Date: Thu, 1 Mar 2007 09:15:08 -0500
Hi,
I have created a document-based application in Cocoa.
I would like to do the following:
Everytime the user clicks on 'Cntr+N" or opens a new
window, I would like the window to open ajacent to the
current window. For example, I will have around 9
windows and I would like them to be displayed in 3x3
grid.
I am new to Cocoa and XCode and am not sure how to go
about doing this.
Thanks,
Dew
I think you can best do this in NSDocuments'
windowControllerDidLoadNib. Assuming you want to distribute your
windows only over the main screen (with multiple screens it becomes a
bit more difficult):
-Use [[NSScreen mainScreen] frame] to get a NSRect of the main
screen. The size of this rect includes the menubar, so you have to
adjust for that when distributing your windows.
-Get an array of documents via [NSDocumentController documents].
-See how many documents there are, and make up some nice algorithm to
distribute their windows equally over the screen. For every document,
use [[[aDocument windowControllers] lastObject] window] to get the
window for the document, make an NSRect with the desired origin and
size, and then use NSWindow's setFrame:display:animate: to get the
window in place.
Good luck, Patrick
p.s. In order to get better answers from this list, you should give
your posts more specific titles, e.g.: "distributing windows over the
screen" instead of the too generic "Cocoa Document-Based Application".
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden