[ Previous | Next | Contents | Glossary | Home | Search ]
Motif 2.1 Programmer's Guide

Making a Selection: SelectionBox

SelectionBox is a BulletinBoard subclass that generally allows the user to select an item from a list. By default, a SelectionBox includes the following children:

  1. A scrolling list of alternatives

  2. An editable text field for the selected alternative

  3. Labels for the list and text field

  4. Three or four buttons

    The default buttons are OK, Cancel, and Help. By default, an Apply button is also created. If the parent of the SelectionBox is a DialogShell, it is managed; otherwise, it is unmanaged.

    An application can add additional children to the SelectionBox. The first child is used as a work area. The value of XmNchildPlacement determines whether the work area is placed above or below the Text area, or above or below the List area. Additional children are laid out in the following manner:


    The first MenuBar child is placed at the top of the window.

    All XmPushButton widgets or gadgets and their subclasses are placed after the OK button in the order of their creation.

    The layout of additional children that are not in these categories is undefined.

    The user can select an item in two ways: by scrolling through the list and selecting the desired item or by entering the item name directly into the text edit area. Selecting an item from the list causes that item name to appear in the selection text edit area. SelectionBox installs accelerators, the value of XmNtextAccelerators, on the text edit widget. The default accelerators bind osfUp, osfDown, osfBeginLine, osfEndLine, and osfRestore events in the text edit widget to SelectionBox actions that select an item in the list and replace the text edit widget value with that list item.

    SelectionBox provides XmNokCallback, XmNcancelCallback, XmNhelpCallback, and XmNapplyCallback lists, which the SelectionBox invokes when the corresponding button is activated. Activation of the OK button may invoke either the XmNokCallback list or the XmNnoMatchCallback list. When the user activates the OK button and either the XmNmustMatch resource is False or the text in the text edit area matches a list item, SelectionBox invokes the XmNokCallback procedures. When the user activates the OK button, XmNmustMatch is True, and the text in the text edit area does not match a list item, SelectionBox invokes the XmNnoMatchCallback procedures.

    SelectionBox has two subclasses, FileSelectionBox and Command, which are described in later sections. XmCreateSelectionDialog creates a standard SelectionBox and a DialogShell parent. XmCreatePromptDialog creates a variant SelectionBox dialog containing a text edit area and label and OK, Cancel, and Help buttons. A PromptDialog has an unmanaged Apply button, and it has no List or List label. It is intended for the application to prompt the user for brief text input.

    The XmNdialogType resource determines which of the standard SelectionBox children are created and managed. The value usually depends on the application's use of the SelectionBox:

    1. XmDIALOG_SELECTION usually indicates a standard SelectionBox dialog.

    2. XmDIALOG_WORK_AREA indicates a SelectionBox outside a DialogShell. The Apply button is unmanaged.

    3. XmDIALOG_PROMPT indicates a PromptDialog.

    4. XmDIALOG_COMMAND indicates a Command subclass.

    5. XmDIALOG_FILE_SELECTION indicates a FileSelectionBox subclass.

      SelectionBox has resources for supplying text, label strings, and list items for its children. The widget IDs of the children of a SelectionBox and its subclasses are not available as resources. The application can retrieve the widget IDs of the automatically created children by using XtNameToWidget or by calling one of the convenience routines Motif provides for this purpose: XmSelectionBoxGetChild, XmFileSelectionBoxGetChild, and XmCommandGetChild.

    6. [ Previous | Next | Contents | Glossary | Home | Search ]