1

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)?

K.Dᴀᴠɪs
  • 9,945
  • 11
  • 33
  • 43
Pep
  • 1,957
  • 2
  • 24
  • 40
  • Are you sure this is VBA and not VB.NET? If it's VBA please specify the application you are using it with. If it's not VBA, please edit your post accordingly – SierraOscar Mar 24 '16 at 19:15
  • @MacroMan That does not look like VB.NET at all, however it looks like [this](http://stackoverflow.com/q/22050996/11683). – GSerg Mar 24 '16 at 19:19
  • @GSerg agreed, a tad *too* much of a coincidence methinks – SierraOscar Mar 24 '16 at 19:20
  • Edited the question to clarify that is the VBA compatible Sax Basic engine that the SDL Passolo localization application uses. – Pep Mar 24 '16 at 20:17

1 Answers1

1

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.

Jenszcz
  • 547
  • 3
  • 9