Common Desktop Environment: Help System Author's and Programmer's Guide

Chapter 11 Handling Events in Help Dialogs

This chapter describes several Help dialog events that an application must be equipped to handle.

Supporting Help Dialog Events

Like other widgets within your application, help windows have some behavior that must be supported by the application.

Hyperlink Events

Most standard hyperlink events are handled internally by the Help System. However, there are four types of hyperlinks that your application is responsible for handling:

When Dialogs Are Dismissed

When the user closes a help dialog, your application needs to know so it can store the dialog in its cache, or destroy it. The general help dialog supports a help closed callback. To detect when a quick dialog is dismissed, add a callback to its Close button.

Quick Help Buttons

The behavior for some of the buttons in quick help dialogs must be handled by your application. These buttons can be managed and unmanaged as needed. You add behavior just like any other push button: using an activate callback.

See Also

Responding to Hyperlink Events

Your application needs to provide support only for the types of hyperlinks used within the help volume to be displayed. In general, it is recommended that you provide support for all link types.

For your application to be notified when a hyperlink is chosen, it must add a hyperlink callback to the help dialog. You must write a callback function that handles the hyperlink appropriately.

To Provide a Hyperlink Callback

  1. Add a hyperlink callback to each help dialog as shown:

    XtAddCallback (helpDialog, DtNhyperlLinkCallback,
                    HyperlinkCB, (XtPointer)NULL);

    Where helpDialog is the widget ID of the help dialog and HyperlinkCB is the name of the callback function for handling hyperlinks.

  2. Write the HyperlinkCB function to handle the hyperlink events that can occur within the dialog.

    Within the hyperlink callback, you have access to the following callback structure (which is declared in <Dt/Help.h>):

    typedef struct
    		int      reason;
    		XEvent  *event;
    		char    *locationId; 
    		char    *helpVolume;
    		char    *specification;
    		int      hyperType;
    		int      windowHint;
    } DtHelpDialogCallbackStruct;

    The hyperType element indicates which type of link was executed. Its possible values are: DtHELP_LINK_TOPIC, DtHELP_LINK_MAN_PAGE, DtHELP_LINK_APP_DEFINE, or DtHELP_LINK_TEXT_FILE. For a description of which structure elements are valid for different types refer to the DtHelpDialog(3) man page.

    The windowHint element indicates a window type. Its possible values are: DtHELP_CURRENT_WINDOW, DtHELP_POPUP_WINDOW, or DtHELP_NEW_WINDOW.


The following function, HyperlinkCB(), illustrates the general structure needed to handle hyperlink callbacks.

HyperlinkCB (widget, clientData, callData)
      Widget     widget;
      XtPointer  clientData;
      XtPointer  callData;
      DtHelpDialogCallbackStruct *hyperData =
         (DtHelpDialogCallbackStruct *) callData;
      switch ((int)hyperData-> hyperType)
            case DtHELP_LINK_TOPIC:
              /* Handles  "jump new view"hyperlinks. */
            case DtHELP_LINK_MAN_PAGE:
              /* Handles  "man page" hyperlinks. */
            case DtHELP_LINK_APP_DEFINE:
              /* Handles ``application-defined" hyperlinks. */
            case DtHELP_LINK_TEXT_FILE:
              /* Handles ``text file" hyperlinks. */

Detecting When Help Dialogs Are Dismissed

To detect when a general help dialog is closed, add the following callback to the dialog:

XtAddCallback (helpDialog, DtNcloseCallback,
                HelpCloseCB, (XtPointer)NULL);

Where helpDialog is the widget ID for the help dialog and HelpCloseCB is the name of the callback procedure you've written to handle closing dialogs.

To detect when a quick help dialog is closed, add the following callback to the dialog's OK button:

XtAddCallback (DtHelpQuickDialogGetChild (helpDialog,
 DtHELP_QUICK_OK_BUTTON), XmNactivateCallback, HelpCloseCB, (XtPointer)NULL);

Where helpDialog is the widget ID for the help dialog and HelpCloseCB is the name of the callback procedure you've written to handle closing dialogs.

Using the Application-Configured Button

The quick help dialog's application-configured button lets you add custom behavior to any quick help dialog. This button can be used for anything you want, but its intended purpose is to provide a path to more help in one of these two ways:

To Enable the Application-Configured Button

  1. Get the button's ID.

  2. Add an activate callback to the button.

  3. Manage the button.


The following code segment gets the button's ID, assigns a callback, and manages the button. It assumes that quickHelpDialog was just created.

Widget  moreButton;
moreButton = DtHelpQuickDialogGetChild (quickHelpDialog,
 XtAddCallback (moreButton, XmNactivateCallback,
                MoreHelpCB, NULL);
 XtManageChild (moreButton);

See Also