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 > AARRGGHH: Springs and Struts

AARRGGHH: Springs and Struts
Thread Tools
Dedicated MacNNer
Join Date: Nov 2000
Status: Offline
Reply With Quote
Jul 8, 2001, 03:29 PM
 
Hello ...

I have a text field (NSTextView, actually) in a vertically-resizable window. Normally, I want the field's bottom edge to keep a constant distance from the window's bottom edge; using Interface Builder to set the field's resizing info with a "height spring" does the trick.

I also have a "smaller window" mode in which the window's bottom edge rides closer to the field's bottom edge. In transitioning to this mode, I want the field to stay put and have the window "shrink up" to it. So, before sending -setFrame:display:animate: to the window, I want to replace the field's "height spring" with a "strut", and its "bottom margin strut" to a "spring".

In Interface Builder, both spring/strut arrangements work as expected. However, I can't seem to get my code to make on-the-fly changes:

<BLOCKQUOTE><font size="1"face="Geneva, Verdana, Arial">code:</font><HR><pre><font size=1 face=courier>
- (<font color = green>void</font>)shrinkWindow
{
[...]
<font color = brown>// Field originally set with <font color = red>"height spring"</font>.</font>
<font color = brown>// During transition, I want the <font color = red>"bottom margin spring"</font>,</font>
<font color = brown>// then I reset the <font color = red>"height spring"</font>.</font>

[myFld setAutoresizingMask:NSViewMinYMargin];
[myWindow setFrame:aRect display:<font color = purple>YES</font> animate:<font color = purple>YES</font>];
[myFld setAutoresizingMask:NSViewHeightSizable];
}
</font>[/code]

What am I missing here?


Thanks,

DayLateDon
     
Dedicated MacNNer
Join Date: Nov 2000
Status: Offline
Reply With Quote
Jul 9, 2001, 12:08 AM
 
Hello ...

Problem solved: Since I was using a "scrolling view", it wasn't the NSTextView's springs and struts I needed to adjust. I had to back up through two levels of "superviews" to get to the surrounding NSScrollView.


<BLOCKQUOTE><font size="1"face="Geneva, Verdana, Arial">code:</font><HR><pre><font size=1 face=courier>
- (<font color = green>void</font>)shrinkWindow
{
[...]
<font color = brown>// Field originally set with <font color = red>"height spring"</font>.</font>
<font color = brown>// During transition, I want the <font color = red>"bottom margin spring"</font>,</font>
<font color = brown>// then I reset the <font color = red>"height spring"</font>.</font>
[[[myFld superview] superview] setAutoresizingMask:NSViewMinYMargin];
[myWindow setFrame:aRect display:<font color = purple>YES</font> animate:<font color = purple>YES</font>];
[[[myFld superview] superview] setAutoresizingMask:NSViewHeightSizable];
}
</font>[/code]

This does the trick. (For a while there, I was stymied by having backed out only one "superview" level, not realizing that I was only to the NSScrollView's "ClipView".)

Regards,

DayLateDon
     
   
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 12:45 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