Changing What Buttons Do

You might want to change the action that a button performs. For example, you might want to display the Table of Contents for your title in a secondary window so that the user can continue displaying the Contents screen while viewing the different topic screens.

The ChangeButtonBinding command allows you to assign any standard Viewer command to any Viewer button. As for the CreateButton, DestroyButton, and DisableButton commands, you enter the ChangeButtonBinding command as part of an exclamation-point footnote in the topic where you want to change the button function. After the user displays the topic with the exclamation-point footnote, the button keeps its new function until the user quits Viewer or opens a new title. (See “Using Viewer Commands,” earlier in this chapter, for information on entering exclamation-point footnotes.) ChangeButtonBinding can change the function of standard Viewer buttons as well as buttons you have authored.

The ChangeButtonBinding command has the following syntax:

ChangeButtonBinding("button-id", "button-command")

The button-ID is the ID, enclosed in quotes, you assigned in the CreateButton command or, for a standard Viewer button, one of the following predefined button IDs:

Button ID Button

btn_contents Contents
btn_search Index
btn_back Back
btn_history History
btn_previous <<
btn_next >>

Button-command is the Viewer command you are executing, enclosed in double quotes. The button-command can also be a function in an external DLL that you've registered as a Viewer command using Viewer's RegisterRoutine command. The HAudioCommand, HAudioDialog, HDisplayBmp, and HAnimateCommand commands are examples of external DLL calls registered as Viewer commands. (See Chapter 18, “Multimedia Viewer Commands,” for more information on how to use RegisterRoutine.)

Summary: Example

To display the Table of Contents topic in a secondary window instead of the Viewer main window, enter the following footnote:

!ChangeButtonBinding("btn_contents", "JumpId(`usa.mvb', `usa_main>contents')")

The JumpId command jumps to the topic given in the command. In this example, USA.MVB is the file where the jump destination appears; “usa_main” is the context string of the jump destination, which is the Table of Contents in the USA sample title. The “>contents” at the end of the context string means that the Table of Contents is displayed in a secondary window defined by type “contents.” (See Chapter 6, “Advanced Authoring Techniques,” for more information on creating secondary windows in a Viewer title.)