I have the following OptionGroup defined in dialog in VBA compatible Sax Basic Engine (embedded for scripting in the localization application Passolo):
Sub Main
.
.
Begin Dialog UserDialog 690,404,"Export and Import Text Files" ' %GRID:10,7,1,1
.
.
OptionGroup .ExportImport
OptionButton 30,77,190,14,"Export for translation",.optExport
OptionButton 20,221,190,14,"Import translations",.optImport
I would like to assign an event handler to capture the change in selection so that I can enable/disable some other controls in the dialog depending on the current selection.
How do I define an event handler for an OptionGroup? Should it be defined at OptionGroup-level or at OptionButton-level (i.e. one event handler for each radio button)?
In Sax Basic/WinWrap Basic the closest thing to an event handler that I am aware of is the (dialogfunc) prototype. Your implementation should handle changes to OptionGroup
values in case 2
: the top radio button will have SuppValue 0.
The dialogfunc in the example below will output text to the Passolo Messages window when you select a radio button:
Sub Main
Begin Dialog UserDialog 690,404, "Export and Import Text Files",.ExpImpDlgFunct
OptionGroup .ExportImport
OptionButton 30,77,190,14,"Export for translation",.optExport
OptionButton 30,221,190,14,"Import translations",.optImport
OKButton 30,280,60,20
End Dialog
Dim dlg As UserDialog
Dialog dlg
End Sub
Private Function ExpImpDlgFunct(DlgItem$, Action%, SuppValue&) As Boolean
Select Case Action%
Case 1 ' Dialog box initialization
Case 2 ' Value changing or button pressed
If DlgItem = "ExportImport" Then
Select Case SuppValue
Case 0:
PSL.Output("Export")
Case 1:
PSL.Output("Import")
End Select
End If
Rem DlgFunc = True ' Prevent button press from closing the dialog box
Case 3 ' TextBox or ComboBox text changed
Case 4 ' Focus changed
Case 5 ' Idle
Rem DlgFunc = True ' Continue getting idle actions
Case 6 ' Function key
End Select
End Function
You can find additional examples of dialogfuncs here and here.