How to use the “2 Button” Notifier dialog box

A reader asked, “When using the 2 button Notifier dialog, how do we know which button was pressed?

The 2 button Notifier dialog alert box displays 3 buttons(!) – the first two have values you specify, such as “Ok” and “Done”, as shown here, and the third is an optional generic “Cancel” button:

Screenshot_2015-09-11-15-07-15

The Notifier component block is a procedure call that has no return value – so how can you determine which button was selected?

The answer is that the selected button is returned to a separate event handler.

Designer View

First, let us set up an example program to demonstrate. Here is a Designer view with a button “Demo the 2 button Notifier”, and two text labels, the last of which  displays the content of the selected button from the Notifier:

Notifier2Buttons_Designer

Drag the Notifier1 component Palette to the work area; it appears beneath the work area as a “non-visible” component.

Blocks Code

The Click event handler for the btnStartDemo button calls the Notifier’s ShowChooseDialog procedure, where we specify the text for Button 1 and for Button 2. That call displays the dialog box on screen.

After the user pressed a button, the Notifier generates an AfterChoosing event. The parameter choice contains the text of the button that was pressed.

Notifier2Buttons_Blocks2

The AfterChoosing event handler copies choice to the text label to show which button was selected. The value of choice can be compared in an if-then block to determine how the app should proceed. If the “Ok” button was pressed, then the status message is set to the color green, otherwise the text is set to blue.

Untitled

2 thoughts on “How to use the “2 Button” Notifier dialog box”

Comments are closed.