Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Trouble with NSView frames

Trouble with NSView frames
Thread Tools
Professional Poster
Join Date: Nov 2000
Location: Tasmania, Australia
Status: Offline
Reply With Quote
Dec 12, 2002, 06:33 PM
 
I'm having problems trying to move and resize NSViews.

I have a NSBox (which is a subclass of NSView), and within that I have two NSTextView objects (which again are subclasses of NSView.

I can move and resize the box view no trouble but using exactly the same code, I cannot get the text views to resize.

I'm using code similar to:

Code:
NSTextView textView; NSRect frameRect; frameRect.origin.x = <value>; frameRect.origin.y = <value>; frameRect.size.width = <value>; frameRect.size.height = <value>; [textView setFrame:frameRect]; [textView display];
(I've also tried "setNeedsDisplay:YES" instead of "display").

Does this all look correct?
     
Senior User
Join Date: Mar 2000
Location: Ithaca, NY
Status: Offline
Reply With Quote
Dec 13, 2002, 11:50 PM
 
I think your problem is probably the fact that a text view, when dragged into a window in Interface Builder, is actually a scroll view with a text view as its document view. So, to move it around, you'll want to change the scroll view's frame, since changing the text view's frame will simply change its size within the scroll view. You can get the scroll view that contains the text view by using the enclosingScrollView method (declared on NSView)>
     
Brass  (op)
Professional Poster
Join Date: Nov 2000
Location: Tasmania, Australia
Status: Offline
Reply With Quote
Dec 15, 2002, 09:05 PM
 
Amongst other problems, that did turn out to be the solution. changing the frame of the enclosingScrollView (along with some other tweaks) fixed it for me.
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 01:57 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2