Example: (custmain.4gl)
Calls to the setActionActive
method from the
ui.Dialog
class have been added to
custmain.4gl to disable and enable menu
actions appropriately to give the user visual cues. An additional
ON ACTION
statement exits the menu if the user
selects
.
Module
custmain.4gl:
01
02
MAIN
03
DEFINE
query_ok SMALLINT
04
05
DEFER INTERRUPT
06
CONNECT TO
"custdemo"
07
CLOSE WINDOW SCREEN
08
CALL
ui.Interface.setImage("smiley")
09
OPEN WINDOW
w1 WITH FORM
"custform"
10
11
LET
query_ok = FALSE
12
13
MENU
14
BEFORE MENU
15
CALL
DIALOG.setActionActive("next",0)
16
CALL
DIALOG.setActionActive("previous",0)
17
ON ACTION
find
18
CALL
DIALOG.setActionActive("next",0)
19
CALL
DIALOG.setActionActive("previous",0)
20
CALL
query_cust() RETURNING
query_ok
21
IF
(query_ok) THEN
22
CALL
DIALOG.setActionActive("next",1)
23
CALL
DIALOG.setActionActive("previous",1)
24
END IF
25
ON ACTION
next
26
CALL
fetch_rel_cust(1)
27
ON ACTION
previous
28
CALL
fetch_rel_cust(-1)
29
ON ACTION
quit
30
EXIT MENU
31
ON ACTION
close
32
EXIT ME
NU
33
END MENU
34
35
CLOSE WINDOW
w1
36
37
DISCONNECT CURRENT
38
39
END MAIN
Note:
- Line
08
The icon for the application windows is set to the "exit" image. - Lines
15
,16
Before the menu is first displayed, thenext
andprevious
actions are disabled. - Lines
18
,19
Before thequery_cust
function is executed thenext
andprevious
actions are disabled - Lines
21
thru24
If the query was successful thenext
andprevious
actions are enabled. - Line
31
Theclose
action is included in the menu, although an action view won't display on the form. If the user clicks the
in the top right of the window, the action on line32
,EXIT MENU
, will be taken.