GetChoice
The GetChoice function opens a dialog showing a binary choice to be made. This function returns the choice index and the button that was clicked. All text labels can be configured or defaults can be used.
|
|
nChoice, bOK = GetChoice( sLabels, n=1, sPrompt=nil, sTitle=nil )
All arguments following sLabels are optional. and assume default values after the last argument you specify. To use a default argument but follow it with a specified argument, use a nil in its place.
The sLabels argument specifies the strings to be used for the 2 bullet labels. These labels are specified in one string separated by a new line character \n, with the top label first. For example, to specify the labels as "First label" and "Second label", pass the sLabels argument as
The choice is returned as nResult = 1 or 2. If the User clicks [OK], then this method returns bOK=true. Otherwise, if the user clicks [Cancel], then this method returns bOK=false.
Example 1. The dialog shown above was created using the following code:
|
|
|
-- labels |
|
-- initial choice |
|
-- prompt |
|
-- dialog title |
Example 2. A default dialog that specifies strings and title would use the following code:
|
|
|
-- labels |
|
-- default initial choice |
|
-- default prompt |
|
-- dialog title |
Example 3. A default dialog with only the strings specified might code like this (you can skip the intermediate nil's:
|
-- labels only |
|
|