It is possible to interact with variable dialogs. Selections in lists, changes in input fields, and selections in lists, can trigger callbacks to a user-defined function. Then, it is also possible to change dialog elements from this callback routine.
You set a local function as a callback via the title input in the variable dialog:
““
The local callback function will now be called up if there are changes in the dialog. The function is declared as follows:
PAR res;
PROC Callback
PAR handle, elemNo, event, eventPar;
IF TYP(elemNo)=STRING THEN
IF elemNo='@combo' AND event=C:CBN_SELCHANGE THEN
IF eventPar=0 THEN // own input, enable input
CADH_VarDialogAccess(handle,[['@input1',C:VDLG_ENABLE,TRUE]]);
ELSE // disable input, set value to zero
CADH_VarDialogAccess(handle,[['@input1',C:VDLG_ENABLE,FALSE],
['@input1',c:VDLG_ASSIGN,0]]);
ENDIF
ENDIF
ENDIF
ENDPROC
res = CADH_VarDialog([['Title',PROC(Callback)], 400, 400 0.4],
[[C:VDLG_Real,'@input1'],'Input1:',2],
[[C:VDLG_StrCom,'@combo'],'Selection:',
['own input','calculate'],[0],TRUE]);
A handle is transferred to the dialog as a code parameter, along with an element identifier, the event, and additional parameters. The possible events are:
Element type |
Event |
Parameter |
Dialog |
Initialization |
none |
|
|
|
Combobox |
Selection |
Current value |
|
|
|
Input field |
Leave field |
Current value |
|
|
|
|
|
|
Button |
activated |
none |
|
|
|
Either the number of the element according to the index in the results array is transferred as the element number, or the name of the element is transferred. As in the example, a name can be defined by transferring an array, with a type and name in its first element, for the dialog element.
Use this function to access the dialog from the callback routine:
Here, the following actions are permitted:
Action |
Description |
Parameter |
|
Assignment to input field |
New value |
|
Selection in combo box |
[position]/value |
|
Activate or deactivate |
TRUE/FALSE |
|
Focus on new element |
Element's ID |
If no action is specified, the value in the input field will be returned. The data is returned as an array, with as many elements as code parameters.