Dialog window to confirm an action

The program Confirm.m3 implements a simple dialog box. It is implemented by defining a new VBT in its own Modula-3 module. A module consists of two files, one for the interface description ConfirmVBT.i3 and another for the implementation ConfirmVBT.m3. This modular approach would be quite natural for most substantial programs, but the programs in this paper are purposely quite small, so this is the only time we use it.

The ConfirmVBT module defines a dialog box that displays a message and two buttons. By default the two buttons are labeled ``Yes'' and ``Cancel'' (this cannot be changed in this rudimentary program). By default the action taken when either button is pressed is to delete the dialog box. These actions can be supplied when the confirm VBT is created. The message must be supplied in any case.

The intended scenario is that some client program is about to take some critical action, like quitting, and wants the user to confirm the action. The client program creates the confirm VBT with the appropriate message and actions associated and installs the VBT. The dialog pops up and the user can chose between cancelling the action or performing it. This sequence is depicted in the following two images:

The main program Confirm.m3 is a simple application with one button, a ``quit'' button. When pressed, a confirm VBT is popped up. The ``yes'' action exits the whole application. The ``cancel'' action invokes the default cancel action which is just to destroy the pop-up dialog. The main program has two subwindows with borders of different colors and textures.