• 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
Positioning an NSView in an NSWindow
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Prev by Date: NSTokenField with NSSmallControlSize in a Table View
  • Next by Date: Getting an NSAttributedString from NSData/NSTextView using Core Data
  • Previous by thread: NSTokenField with NSSmallControlSize in a Table View
  • Next by thread: Re: Positioning an NSView in an NSWindow
  • Index(es):
    • Date
    • Thread