Example: custmain.4gl
Calls to the ui.Dialog.setActionActive method have been added to
custmain.4gl to disable and enable menu actions appropriately to give
the user visual cues. An additional ON ACTION close statement exits the menu
if the user selects the "X" in the upper right corner of the interface.
Module custmain.4gl:
1 IMPORT FGL custquery
2
3 MAIN
4
5 DEFER INTERRUPT
6
7 CONNECT TO "custdemo"
8
9 CLOSE WINDOW SCREEN
10 OPEN WINDOW w1 WITH FORM "custform"
11 ATTRIBUTES(TEXT="Customer")
12
13 MENU "Customer"
14 BEFORE MENU
15 CALL setup_dialog(DIALOG,FALSE)
16 ON ACTION query ATTRIBUTES(COMMENT="Search for customers")
17 VAR can_nav = custquery.query_cust()
18 CALL setup_dialog(DIALOG,can_nav)
19 ON ACTION next
20 CALL custquery.fetch_rel_cust(1)
21 ON ACTION previous
22 CALL custquery.fetch_rel_cust(-1)
23 ON ACTION quit
24 EXIT MENU
25 ON ACTION close
26 EXIT MENU
27 END MENU
28
29 CLOSE WINDOW w1
30
31 DISCONNECT CURRENT
32
33 END MAIN
34
35 PRIVATE FUNCTION setup_dialog(dlg ui.Dialog, can_nav BOOLEAN) RETURNS ()
36 CALL dlg.setActionActive("next",can_nav)
37 CALL dlg.setActionActive("previous",can_nav)
38 END FUNCTIONNote:
- Lines
14and15: Before the menu dialog gets the control, thenextandpreviousactions are disabled, by using thesetup_dialogfunction. - Lines
35thru38: Thesetup_dialogfunction is in charge of action activation or de-activation. Thedlgparameter is the dialog object, andcan_navis the boolean value that indicates if navigation actions can be enabled. - Lines
17and18: The can_nav boolean variable is created in the local scope, from the returned value of thequery_custfunction. According to this boolean value, thenextandpreviousactions are enabled or disabled. - Lines
19thru22: If the query was successful thenextandpreviousactions are enabled and will trigger the row fetch. - Line
25and26: Thecloseaction is included in the menu, although an action view won't display on the form. If the user clicks the "X" in the top right of the window, theEXIT MENU, will be taken.