ShowYesNo - cBaseLocalControlHost
Displays an information dialog with Yes and No buttons
Type: Procedure
Parameters
| Parameter | Type | Description |
|---|---|---|
| hoCallBack | Handle | Handle of callback object |
| hmCallback | Handle | Handle of callback message |
| sMessage | String | Message to be displayed |
| sOptCaption | String | (Optional) Message title |
| eOptDfltBtn | Integer | (Optional) The button that should act as the default button (when Enter is pressed on the keyboard) |
Syntax
Procedure ShowYesNo Handle hoCallBack Handle hmCallback String sMessage String sOptCaption Integer eOptDfltBtn
Call Example
Send ShowYesNo hoCallBack hmCallback sMessage sOptCaption eOptDfltBtn
Description
The ShowYesNo message is used to handle yes/no confirmations. It uses the lower level ShowMessageBox, which can also be used to process other types of custom confirmations. The ShowInfoBox message can be used to display a simpler message and title caption.
Using Callbacks
ShowYesNo, ShowYesNoCancel and ShowMessageBox use the concept of a callback object and message. These are passed to the procedure and passed to the client. Upon completion the client makes a server call, which will send a callback message to the callback object passing the results of the confirmation. Therefore, a confirmation must consist of code for creating the confirmation and a method handler to handle the response.
Valid values for eOptDfltBtn parameter are:
| Constant | Meaning |
|---|---|
| cmClose | Dialog was closed |
| cmYes | Dialog Yes button was clicked |
| cmNo | Dialog No button was clicked |
| cmCancel | Dialog was cancelled |
This shows an example where a client button click will call OnClick, which then performs a yes/no confirmation. The result of this confirmation results in a call to the ButtonCallback method with the results.
Object oChangeButton is a cWebButton
Set psCaption to "Click me"
{ WebProperty=Server }
Property Boolean pbAllowUpdate False
Procedure ButtonCallback Integer eConfirmMode
Boolean bAllowUpdate
WebGet pbAllowUpdate to bAllowUpdate
WebSet pbAllowUpdate to False
If (bAllowUpdate and eConfirmMode=cmYes) Begin
WebSet psCaption to (CurrentDateTime())
End
End_Procedure
// this tells the system that this method is allowed for this object
WebPublishProcedure ButtonCallback
Procedure OnClick
// do confirmation and call this object's ButtonCallback message with the results
WebSet pbAllowUpdate to True
Send ShowYesNo (Self) (RefProc(ButtonCallback)) "Update this" "Question"
End_Procedure
End_Object
When callbacks are used, the callback must be an allowable callback for the callback object. This is accomplished by publishing the method, which is what the WebPublishProcedure command does here. This is done to make sure that only known methods are processed on the server.
Publishing the callback also means that the client can call that method. If the callback is only valid after a server-side condition has been met, always re-check that condition inside the callback before performing the action. In the example above, pbAllowUpdate is a Server Web Property, so its value is kept on the server and can be used by ButtonCallback to verify that the update is currently allowed.
Confirmation Messages
Note that this confirmation is already built into the data entry framework and save, delete and data-loss confirmations are be made setting the Verify_Save_Msg, Verify_Delete_Msg and Verify_Data_Loss_Msg to an appropriate confirmation method. By default, they are enabled and they call the built in SaveConfirmation, DeleteConfirmation and DataLossConfirmation methods.
To insert a line break, insert "\n\r" into your text.
Procedure ConfirmResponse Integer eConfirmMode
// do something
End_Procedure
Procedure OnClick
Send ShowYesNo (Self) (RefProc(ConfirmResponse)) "This is the first line of text.\n\rThis is the second line of text."
End_Procedure
See Also