HyperCard Corner: Hidden Fields

By Greg Raven
Volume 6 no. 1 (January 1988), page 8

Although you won’t find it listed as an attribute in the Field Info… window under the Objects menu, HyperCard lets you decide which fields (and buttons) will be visible and which won’t. To hide a visible field, select Message from the Go menu, type in hide field 1 (or whichever field you wish) and press <RETURN>. The named field will disappear from your screen. To make it reappear, again select Message from the Go menu and type in show field 1. Presto, it’s back.

One way to make use of fields that you can hide and show is as pop-up notes. A good example of this can be found in Apple’s Help stack. Open the stack and click on HyperTalk. The little word balloon in the upper right-hand corner is a button that, when clicked, shows the address of the Apple Programmer’s and Developer’s Association.

The script that makes this pop-up note appear is:

on mouseUp
    show card field 2
end mouseUp

Obviously, when programming the stack, card field 2 was predefined and the information about the APDA was entered in it. If you had help information that was pertinent on all cards in the stack, you would of course use a background or stack field instead of a card field.

There is a problem using hidden boxes, however. When you use the Find… command in the Go menu, HyperCard will look not only in the visible fields but in the invisible fields, too. If after issuing the Find… command HyperCard displays a card but you don’t see the cursor, check to see if the search string has been located in a hidden field.

The Message Box

For this very reason, I tried to find a different method of alerting users of my stacks to important but transient information. Because HyperCard offers a message box free of charge, why not use it?

For example, on my Phonebook stack I have installed a View button. The original View button’s script is:

	on mouseUp
		show all cards
	end mouseUp

This works fine, but it may leave the user wondering how to stop the cards from flashing by. I expanded the script to read:

	on mouseUp
		put Click anywhere on the screen to stop into msg
		show msg
		show all cards
		doMenu Message
	end mouseUp

The second line of the script puts the message I wanted into the message container. The third line shows the Message Box, which by this time holds the message I want the user to see. The fourth line starts flashing the cards.

If I had stopped the script there, clicking anywhere on the screen would have caused HyperCard to stop flashing the cards. It would also have left the Message Box on the screen. This not only clutters the screen, in the case of my Phonebook stack it covers some of the information on the card. Therefore, I included the fifth line of the script to toggle the Message Box off when the user is done with it. Although there is no explicit command to tell HyperCard that the user is done viewing the cards, the fifth line of the script is not executed until after it has completed executing the fourth line. In other words, the user must click somewhere on the screen to stop the show all cards command so HyperCard will know it is time to go on to the next command.

Instead of the third line show msg I could have used doMenu ‘Message’. Using show msg is better in this case because it doesn’t matter whether or not the message box is already on the screen. If the Message Box is on screen when a doMenu ‘Message’ command is encountered, the Message box is taken off the screen.

A Temporary Field

Displaying help information in either a card field or the Message Box is fairly fast, but neither works in all situations; a card field gets in the way when we want to Find … something, while the Message Box doesn’t hold very much text. What is needed is something that holds more information yet doesn’t get in the way when we issue the Find … command. One way of doing this is with the following script:

	 on mouseUp
		set the cursor to 4
		set the lockScreen to true
		get userLevel
		put it into UL
		set userLevel to 4
		doMenu New Field
		choose Browse tool
		set style of card field 1 to rectangle
		put Be sure to type --- & return into it
		put  Close File ‘Batch’ & return after it
		put --- into the Message Box after it
		put when you are done exporting addresses or labels after it
		put it into card field 1

		doMenu New Button
		set the name of card button 1 to Okay
		set autoHilite of card button 1 to true
		set showName of card button 1 to true
		choose Browse tool
		set the lockScreen to false
		set the cursor to 2
		show card field 1
		repeat until the mouse is down
		show card button 1 at the mouseh, the mousev
		end repeat
		set the cursor to 4
		set the lockScreen to true
		choose Field tool
		click at location of card field 1
		doMenu Clear Field
		choose Button tool
		click at location of card button 1
		doMenu Clear Button
		choose Browse tool
		set userLevel to UL
		set the lockScreen to false
	end mouseUp

Here’s what this script does:

Setting the cursor to 4 changes the shape of the cursor from the hand (Browse tool) to the watch so the user knows that something is going on. Locking the screen freezes the screen image so as the script executes the user will not see a confusing display of fields and buttons.

We are going to ask the script to create a field and a button, so the user level must be set high enough (to authoring, which is number 4, or scripting, which is number 5) to allow this to take place. Not all users need or want to be at the higher levels, so we get the current user level, put it into the variable UL, then set the user level to 4.

Now we create the field into which we are going to place the help text. Selecting the Browse tool after creating the new field confines the new field to only the card we are looking at. Otherwise, HyperCard for some reason will put the field on all the other cards in the stack when the Button tool is selected. Setting the new field style to rectangle makes it easier to see the field text against a busy background.

The next four put statements store the help text we want in the variable it, and the last put statement fills the card field with the help text. Notice that the help text is formatted so the user will better understand what he needs to do.

Once we display the help text in our temporary field, we must provide an easy way of getting rid of it. Why not a temporary button? The next section of script creates a button to do just that. After creating the button,

the next three lines name it, set the highlight (for when the user clicks on the button), and show the name of the button. Again we choose the Browse tool to keep HyperCard from becoming confused.

At this point, the housekeeping is done for the time being so we tell HyperCard to release the screen and set the cursor to the thin crosshairs (property number 2). Then we show the user the card field 1.

The next three lines allow us to have a little fun with the user. We show the card button wherever the user moves the mouse, so the Okay button is always beneath the cursor! As soon as the mouse is clicked, the script proceeds out of the repeat loop on to the next instruction.

The user has clicked on the Okay button, indicating that he has read the instructions and wants to move on. Now the script must eliminate the temporary card field and card button we created. Because this takes a moment, the cursor is set to the watch (property 4) so the user knows something is going on. We also lock the screen so the user isn’t distracted by the housekeeping work we must do.

We tell HyperCard to choose the field tool, to select card field 1, and then to delete that field. Choosing the button tool, we do the same for card button 1. Both temporary items have now been deleted, so we select the Browse tool, restore the user level to where it was when the script started executing, and release the screen. Notice that we did not have to set the cursor property back. HyperCard will automatically do that after the end mouseUp command at the end of the script.

The drawback to this method is that it is slow, but the hope is that after a couple times the user will not need to refer to the help button, and compared to having hidden fields containing help information, these temporary fields do not interfere with Find…. For short messages I still use the Message box, but for up to five short lines of help text, these temporary card fields are real useful.