• 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
Re: Interface Builder Question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Interface Builder Question


  • Subject: Re: Interface Builder Question
  • From: Matt Gemmell <email@hidden>
  • Date: Sat, 7 Sep 2002 00:29:51 +0100

On Friday, September 6, 2002, at 11:28 pm, Shoaib wrote:

I have a resizable window that has a NSTableView and some additional text
fields above it. When the window is resized, I want the NSTableView to size
accordingly but I don't want the text fields to move. In other words I want to
"lock" the size and position of the text fields. What happens currently when I
resize is the NSTableView grows or shrinks (as desired) but the text fields
loose their original location.

Is there anyway to lock the size and position of text fields in Interface
Builder?

Select one of the text fields, and go to the Size pane of the inspector (you can press command-3 to show that pane, and to show the Inspector if necessary).

The big "Autosizing" box at the bottom allows you to control how the object sizes itself and positions itself when its window is resized. The smaller box in the centre represents the object you're editing; the text field in this case. Make sure that both the horizontal and vertical lines are straight - this will mean that the object will not resize when the window resizes.

Now, you want to make sure that the object remains in the same place - i.e. a constant distance from certain sides of the window. Let's assume that you want to keep the text field in the same place relative to the top-left of the window. You want to make it keep a constant distance from the top and a constant distance from the left of the window. The four lines outside the smaller box represent the distances between the object and the window's edges. So, you'll want to make sure that the leftmost line and topmost line are straight (meaning that the distance between your text field and the top of the window remains the same, as does the distance between the text field and the left of the window). However, you want to make the object able to be a variable distance from the right and from the bottom of the window; accordingly, you want to make the rightmost and bottom lines be springy. You can click any line to toggle between straight and springy.

You should repeat the above process for the other text field, and tailor the steps above to whatever edges of the window you want the text fields to remain positioned relative to.

Remember that you can test your interface within Interface Builder by pressing command-R, and try resizing there - there's no need to go back into Project Builder and run the whole project. Remember also that, whilst editing your interface, if you hold the ctrl key whilst resizing a window, all the objects in it will respect their settings in the "Size" panel of the Inspector (these settings are often called the "sizing springs", or similar). That's an extremely useful (indeed, sanity-preserving) feature.

It can take a while to get used to the springs, and it sometimes takes a little bit of thought and/or experimentation to get the resizing/positioning that you want, but it's not difficult and offers good control of your UI.

Best,
-Matt

--
Matt Gemmell
Scotland Software
http://www.scotlandsoftware.com/
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >Interface Builder Question (From: "Shoaib" <email@hidden>)

  • Prev by Date: Re: Interface Builder Question
  • Next by Date: Re: Interface Builder Question
  • Previous by thread: Re: Interface Builder Question
  • Next by thread: Carbon books for Cocoa programmers
  • Index(es):
    • Date
    • Thread