Showing One Object While Hiding Others

Here’s an example of cascading a custom message to build a sequence of actions where displaying one object selectively hides others.

Say your page displays a map showing the locations of five company offices. For each location, a button superimposes a text box on the page profiling that office’s activities. When a site visitor clicks a location, you want to hide any profile that’s currently visible, and then display the one describing the selected location.

  1. In Page view, place the buttons and text boxes in the Layout area, arranging them however you want.

  2. Select one of the buttons and create a custom message called HideAllProfiles, as described in Tailoring Actions with Custom Messages.



     

  3. To each button, add an action, as described in Adding Actions to Objects and Pages, so clicking the button cascades the HideAllProfiles message to the Layout.

In the Set Action dialog, enter Mouse, Clicked in the When field; the Layout in the Target field; and Custom, HideAllProfiles in the Message field. Also, check the Cascade message option.

  1. Add a second action to each button so clicking it targets a Show message to the text box associated with the button.

In the Set Action dialog, enter Mouse, Clicked in the When field; the text box this button should display in the Target field; and Object, Show in the Message field.

  1. Select each text box, and on the Actions tab of the Properties palette, clear the Object initially visible in browser option.
     


 

  1. Add an action to each text box that’s triggered by the HideAllProfiles message and hides the text box.

In the Set Action dialog, enter Custom, HideAllProfiles in the When field; the text box itself in the Target field; and Object, Hide in the Message field.

Then preview the page. Clicking a button should send HideAllProfiles as a cascading action message to the Layout. The Layout doesn’t have any actions triggered by this message so it doesn’t respond. But it does cascade the message down to its embedded objects. As a result, every object on the page receives the message. But only those objects with actions triggered by the message—the text boxes—respond by hiding themselves. Next, the button sends a Show message to its associated text box, which makes itself visible.

Without cascading messages you’d have to add four additional actions to each button—one for hiding each text box. If you didn't use a custom message to trigger the text boxes to hide, cascading a Hide message to the Layout would hide every object on the page.