Positioning an NSView in an NSWindow
Positioning an NSView in an NSWindow
- Subject: Positioning an NSView in an NSWindow
- From: "Simon Raisin" <email@hidden>
- Date: Mon, 16 Jul 2007 21:14:32 -0400
Hi,
I have added an NSView instance to my main NSWindow via its addSubView:
instance method.
The new view takes up the bottom 1/2 of my window and I'd like it to be
positioned at the top 1/2. Note that I'm creating this view at runtime so I
can't use Interface Builder to position it ahead of time.
I realize that the coordinate systems of the window and the view are
different, but I thought that I could just use NSView's convertPoint::
method to obtain the correct origin point for my view, but that doesn't seem
to be helping.
pseudo code:
MyView* myView = [make my new view]
NSRect myViewRect = [myView bounds];
// convert the origin point of the view into the proper point for the window
NSPoint newOrigin = [myView convertPoint:myViewRect.origin fromView:nil];
myViewRect.origin = newOrigin;
[myView setBounds:myViewRect];
[[myWindow contentView] addSubView:myView];
I'm obviously doing something wrong... :(
Any pointers would be appreciated!
-CxT
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please 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