Monday, November 20, 2017

#1 2007-01-01 08:00:26 am

T.J. Mahaffey
Administrator
From:: Arkansas, USA
Registered: 2002-11-20
Posts: 238
Website

Applescript Studio: About the About Box

One of the more enjoyable parts of developing Mac software is the venerable about box. Some like to have fun with it and add goofy company names and credit distant relatives or caffeine-soaked foodstuffs. Others prefer to keep their about box serious, clean and no-nonsense. Whichever type of developer you are, it may not be completely obvious how to edit the information which is automatically inserted into your project's default about box. Particularly if you've started fresh with a new one and didn't clone one of Apple's example projects.

At build time, Project Builder will insert the information from your "InfoPlist.strings" file into the default about box. (Note the default about box will not appear in Interface Builder as its own window. This window is a behind-the-scenes sort of object and is auto-magically handled for you based on the information you've entered into the appropriate places.) [See Fig. 1]


http://files.macscripter.net/unscripted/plist.jpg


Figure 1. - InfoPlist.strings settings
Now, if you'd like to add additional textual information to the about box, you may do so by adding a "Credits.rtf" file to your project. The best part is that Project Builder already knows to 'look' for such a file and inserts its contents into the about box, if the file exists. If not, PB doesn't care and will build the about box without it.

First, create a text file in OS X's TextEdit application. Lucky for most starving amateur programmers, it comes free with OS X. Next, type and format your text and save the file as "Credits.rtf". [See Figs. 2, 3] The file name is important and it's case sensitive, so be sure to type it exactly that way. TextEdit's default file format is 'rtf' and it will flag you if an attempt is made to save it otherwise or to use a file extension like 'txt'.

http://files.macscripter.net/unscripted/textdoc1.jpg


Figure 2. -Create an RTF text file.
http://files.macscripter.net/unscripted/saveas_rtf.jpg


Figure 3. - Save as "Credits.rtf"

Next, open your project in Project Builder and choose "Project --> Add Files..." from Project Builder's menu bar.[See Fig. 4]

http://files.macscripter.net/unscripted/adfiles_menu.jpg


Figure 4. - PB's "Add files" menu.
Navigate through the resulting dialog and find your "Credits.rtf" file. Select it and click "Add". You will then be presented with the following dialog [See Fig. 5]

http://files.macscripter.net/unscripted/addfilesdialog.jpg


Figure 5. - "Add Files" dialog.

For the purposes of this tutorial, we're going to skip the next two settings.Leave "Reference Style" at the "Default" setting and leave "Recursively creategroups for any added folders" selected in that set of radio buttons.

Our final step is to select our 'target' under the "Add To Targets" list. Inmost beginner projects, there will be only one target which happens to be named something remarkably close to the name of your application. Just be sure thistarget is highlighted and selected. If your project has multiple targets, youprobably don't need this tutorial anyway and should be solving problems likeworld hunger or discovering anti-gravity.

Finally, click "Add". After you've added your credits file, you'll see it in the left-hand pane of your Project Builder window. [See Fig. 6]

http://files.macscripter.net/unscripted/addedtextfile.jpg


Figure 6. - Added credits file in your Project Builder window.
Also, have a look in your project's folder in the Finder and you should see the "Credits.rtf" file has been copied there, according to your settings in the previous step. [See Fig. 7]

http://files.macscripter.net/unscripted/addedtofolder.jpg


Figure 7. - Added credits file in your project's folder.

Now, build and run your project and select the "About..." menu option. You should then see your enhanced dialog, including the information contained within your credits file. [See Fig. 8b]

http://files.macscripter.net/unscripted/about_before.jpg


http://files.macscripter.net/unscripted/aboutbox_after.jpg


Figure 8a. - Our revised About box before.
[b]Figure 8b. - [b]Our revised About box after.


Reasons this might not work for you:

1. The name of your credits file wasn't typed correctly. Double check that it ends in ".rtf" and that the first letter ("C") is capitalized.

2. Your credits text file was created in the wrong format (ie Word, txt, etc.) Your project will only recognize 'rich text format' for inclusion in your project as credits.

3. A target wasn't selected in the final "Add Files" dialog. Be sure that it was not only highlighted, but also selected. The color difference between these two may be a bit confusing for new users. In my case, highlighting is a grayish-blue color, but actual selection is a darker blue.


Some developers use fancy graphics and pictures in their about boxes. You can do this in a very simple form by dragging images into your document within TextEdit and saving your credits as "Credits.rtfd" instead. Your pictures will show up inline with your text. It's not pretty, but it works. [Thanks, JJ!]

This concludes the current edition ofunscripted. Although it isn't necessary to include me in your own about box, we never say no to a link back to MacScripter! wink Be well and we'll see you next time.

T.J.


T.J.
tj@tjmahaffey.com


Filed under: ASS, Studio, Mahaffey, About_Box

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)