Adding message prompters
An easy way to inform users of a condition occurring or to prompt them for confirmation is through a message prompter. This section shows how to add a message prompter to AddressApplication, which you created in Using a Form Input Checker part.
For some applications, you might want to prompt users to confirm a request to exit a program or to delete a file. To prompt users to confirm that they want to exit AddressApplication, you do the following:
1. Open a Composition Editor on AddressView and add a Message Prompter part to the free-form surface.
Prompters icon, the Prompters category, contains Message Prompter icon, the Message Prompter part.
2. In the settings of the Message Prompter part, define the icon and button types and the text to be shown.
For this example, specify XmICONQUESTION for the iconType property, XmYESNO for the buttonType property, and XmDEFAULTBUTTON1 for the defaultButtonType property. Specify text such as Confirm Cancel for title and Do you really want to cancel? for messageString.
3. Select OK.
To display the message prompter when a user tries to close the Enter an Address window, delete the existing connection to the Cancel push button and replace it with two other connections:
1. Connect the clicked event of Cancel to the promptFor: action of the Message Prompter part.
2. Connect the okYesRetry event of the Message Prompter part to the closeWidget action of the window.
After you make the connections, the Composition Editor shows:
Prompter parts with connections
Now, run the application, select Cancel, and test the message prompter. The prompter looks like the following:
Prompter
Note that the prompter has an icon that signifies a question. If you select a different icon type, such as XmICONERROR, the prompter uses a differenticon. Changing the message type provides more information on message types.
This example shows how to make only one type of prompter. Try the other options available for message prompters. For message prompters that do not require a parameter, such as informational messages, simply connect an event to the Message Prompter part's prompt action. For message prompters that let you interact with other windows while the prompter is open, select XmPRIMARYAPPLICATIONMODAL for prompterStyle in the settings. Depending on the platform you are using, the default modal might require the user to respond to the prompter before interacting with other windows.
For information on displaying message prompters using Smalltalk code, refer to the Programmer Reference.
Last modified date: 07/23/2020