[Previous] [Contents] [Index] [Next]

PtAskQuestion()

Display a question and request a response from the user

Synopsis:

int PtAskQuestion( PtWidget_t *parent,
                   char const *title,
                   char const *question,
                   char const *font,
                   char const *btn1,
                   char const *btn2,
                   char const *btn3,
                   int def_btn );

Description:

This function displays a dialog that asks the user a question and that contains up to three buttons so the user can answer the question. The function works modally, which means that it processes Photon events and won't return until the user chooses a reply.

The title argument defines a title for the dialog. If you don't want a title, set the argument to NULL.

The question argument lets you specify the question you want to ask. The font argument lets you choose the font for the question text; the default is helv12.

The btn1, btn2, and btn3 arguments let you specify the text of buttons 1, 2, and 3. Buttons 2 and 3 are optional, so if you don't want to display one or both of these, set the corresponding argument to NULL.

All three button-text arguments let you to define shortcut keys. Simply place & in front of the character that will act as the shortcut. For example, if you specify &Yes, the Y will be underlined in the button. To select the button, the user can press y or Y.

The def_btn argument specifies the number of the button that will act as the default when the user presses Enter. The text of the default button is always displayed in bold.

Note that the user can change the default by pressing Tab.

Returns:

The number of the button the user selected.

Examples:

switch( PtAskQuestion( base_wgt, NULL, 
                     "File has not been saved. Save it?", 
                     "helv14", "&Save", "&Discard", 
                     "&Cancel", 1 ) ) {

    case 1:  /* yes */
        /* save and return back */
        if ( Pt_HALT == file_save( widget, data,
                                   cbinfo ) )
            return;
        break;

    case 2:  /* no */
        /* continue processing */
        break;

    case 3:  /* cancel */
        /* return back */
        return;
    }

Classification:

Photon

Safety:
Interrupt handler No
Signal handler No
Thread No

See also:

ApError()

PtMessage in the Widget Reference


[Previous] [Contents] [Index] [Next]