Lugaru's Epsilon
Programmer's
Editor

Context:
Epsilon User's Manual and Reference
   Primitives and EEL Subroutines
      Input Primitives
         . . .
         Other Input Functions
         Dialogs
            Standard Dialogs
            Button Dialogs
            Windowed Dialogs
         The Main Loop
         . . .

Previous   Up    Next
Standard Dialogs  Primitives and EEL Subroutines   Windowed Dialogs


Epsilon User's Manual and Reference > Primitives and EEL Subroutines > Input Primitives > Dialogs >

Button Dialogs

short button_dialog(char *title, char *question,
                    char *yes, char *no, char *cancel,
                    int def_button)

The button_dialog( ) primitive displays a dialog having one to three buttons. By convention, these buttons have meanings of "Yes", "No", and "Cancel", but the labels may have any text. Set the cancel parameter to "" to use a dialog with two buttons. Set both cancel and no to "" if you want a dialog with one button. Put & before a character in a button label to make it an access key; it will be underlined, and pressing the key will act like clicking that button. Use && for a literal & character. The parameter title specifies the title of the dialog. The parameter question holds the text to display in the dialog next to the buttons.

Set def_button to 1, 2, or 3 to make the default button be the first, second or third. Any other value for def_button is the same as 1. Canceling or closing the dialog is equivalent to pressing the last defined button.

The primitive returns 1, 2, or 3 to indicate which button was pressed. It sets the key_is_button variable to its return value if the user actually clicked a button, or to zero if he pressed a key to end the dialog. It sets key and full_key to indicate the pressed key (uppercased), or to 'Y', 'N', or 'C', respectively, if the user clicked one of the buttons.

If the user clicked the dialog's close box, the primitive returns 3, setting key_is_button to 4, and key and full_key to the abort key. If the user pressed the abort key, the primitive returns the code for the last button, setting key_is_button to 0, and key and full_key to the pressed key.

This primitive only works in the Windows version of Epsilon; read on for similar functions that work everywhere.

int ask_yn(char *title, char *question, char *yes_button,
           char *no_button, int def_button)
ask_3way(char *title, char *question, char *prompt,
         char *a1, char *a2, char *a3, int def)

The ask_yn( ) subroutine defined in basic.e asks a Yes/No question. Under Windows, it uses a dialog. The parameters specify the title of the dialog, the text of the question displayed in it, and the text on its two buttons (typically "Yes" and "No", but sometimes "Save" and "Cancel" or the like). Put & before a character in a button label to make it an access key; it will be underlined, and pressing the key will act like clicking that button. Use && for a literal & character.

Set def_button to 0 for no default, 1 to make the first choice "Yes" the default, or 2 to make the second choice "No" the default. (Under non-Windows versions, no default means that just hitting <Enter> won't return from this function; you must choose an option. Under Windows, no default is the same as a default of "Yes".) The function returns 1 if the user selected the first option "Yes" or 0 if the user selected the section option "No". Non-Windows versions of Epsilon only use the question and def_button parameters. They modifies the prompt to indicate the default, if any.

The ask_3way( ) subroutine is similar, but asks a question with three possible responses. Epsilon always displays the prompt; GUI versions also display a dialog with the specified title and question. The first letter of each answer is its shortcut key; put an ampersand "&" before another letter in an answer to use that as the shortcut key instead. The value def may be 1, 2, or 3 to make that answer the default, or 0 for none. The subroutine returns 1, 2, 3 as its response, or 0 if the user aborted.

int get_key_response(char *pr, char *valid, int def, char *helpcmd)

The get_key_response( ) subroutine waits for the user to type a valid key in response to a prompt pr. The parameter valid lists the acceptable characters, such as "YN" for a yes/no question. (But see the ask_yn( ) subroutine, more suitable for yes/no questions.) The def parameter, if greater than zero, indicates which key should be the default if the user presses <Enter>. If the helpcmd parameter is non-null, Epsilon displays help on that topic if the users presses ? or another help key. The subroutine returns the selected key.



Previous   Up    Next
Standard Dialogs  Primitives and EEL Subroutines   Windowed Dialogs


Lugaru Copyright (C) 1984, 2012 Lugaru Software Ltd. All Rights Reserved.