macdevcenter.com
oreilly.comSafari Books Online.Conferences.

advertisement

AddThis Social Bookmark Button

Modifying Stickies
Pages: 1, 2, 3, 4

Adding a Ruler

Rulers are a standard part of "TextView" objects, that big white area you selected and updated in the previous section of this article. In this section, you'll discover how to talk to the TextView and tell it to show and hide its ruler.

  1. Return to Interface Builder.

  2. Locate the Palette and make sure you're looking at the set of Controls (Cocoa-Controls). If not, click the second button in the toolbar at the top of the window.

  3. On the Palette, locate the disclose button. It is the right-facing triangle on the top line of buttons, just below the toolbar.

  4. Drag a disclose button out from the Palette and onto the Stickies Window Editor. Drop it on the right side of the Stickies Drag Bar.


Drag items from the Palette to add them to a Window Editor.

  1. Select the new button and adjust it as needed, so it appears toward the right side of the drag bar but does not overlap onto the Scroll View. (Do not put it all the way at the end. Leave some room to the right for the built-in Stickies features.)

  2. In the Info Editor, choose Size from the pop-up (CMD-3).

  3. In the Size palette, click the left-most and bottom-most lines to turn them from a straight line into a spring. This tells Interface Builder to keep the new button in the top-right corner and ignore any resizing to the left and bottom.


Adding the springs to the Size palette tells Interface Builder to ignore resizes to the left and below. This fixes the new button to the upper right-hand corner.

  1. Choose File -> Save (CMD-S) to save your changes to disk.

  2. Return to the Stickies application.

  3. Open a new Sticky (CMD-N) and test the new button. As yet, it will not do anything interesting, but each time you click it the arrow will change from pointing right to pointing down and back.


The new disclosure button should toggle between pointing right and pointing down.

  1. Return to Interface Builder.

  2. Press the Control key and hold it. Control-drag from the new disclose button to the large white TextView. A bent line will follow your drag.


Control-drag to make a connection from one Interface item to another. Here, you Control-drag from the disclose button to the TextView.

  1. Finish your drag with the cursor in the middle of the TextView. The Connections palette appears in the Info Editor.

  2. Scroll down to toggleRuler: and double-click it. A dot appears to the left of toggleRuler:, indicating that the connection has been made.


After double-clicking, a dot appears to the left of the name to indicate that a connection has been made. Here, clicking the disclose button sends the toggleRuler: message to the TextView object.

  1. Choose File -> Save (CMD-S) to save your changes to disk.

  2. Return to the Stickies application.

  3. Open a new Sticky (CMD-N) and test the new button. Now, when it is clicked a ruler appears. This ruler allows you to set the spacing, styles, tabs, and more for your Sticky. Click the disclose button again and the ruler disappears. Each click toggles the ruler on and then off and then on again, etc.

Pretty cool, eh?

Time to take it to the next level.

Pages: 1, 2, 3, 4

Next Pagearrow