Windows have four focus events with which you can use a focus trigger. The following table explains each focus event, and the corresponding value of the focus_type parameter required in the Trigger_RegisterFocus() function:
Focus event |
Description |
Value of focus_type |
---|---|---|
pre |
Occurs each time the window opens or restarts. |
TRIGGER_FOCUS_PRE |
post |
Occurs each time the window closes. |
TRIGGER_FOCUS_POST |
activate |
Occurs each time the window opens or moves to the front. |
TRIGGER_FOCUS_ACTIVATE |
|
Occurs when you choose Print from the File menu. |
TRIGGER_FOCUS_PRINT |
context menu |
Occurs when the context menu for the window is displayed. |
TRIGGER_FOCUS_CONTEXT_MENU |
This trigger is activated when the Customer Maintenance window restarts, and runs the window’s pre script. The Customer Maintenance window restarts when the user clicks the Save, Delete or Clear buttons.
{Name: Startup} local integer l_result; l_result = Trigger_RegisterFocus(anonymous(window RM_Customer_Maintenance of form RM_Customer_Maintenance), TRIGGER_FOCUS_PRE, TRIGGER_AFTER_ORIGINAL, script IG_Restart_Contact_History); if l_result <> SY_NOERR then warning "Trigger registration failed."; end if;
The trigger processing procedure simply restarts the third-party form:
{Name: IG_Restart_Contact_History} clear form IG_Contact_History; unlock 'Customer Number' of window IG_Contact_History of form IG_Contact_History;
This trigger is activated when the context menu for the Customer Maintenance window is displayed.
{Name: Startup} l_result = Trigger_RegisterFocus(anonymous(window RM_Customer_Maintenance of form RM_Customer_Maintenance), TRIGGER_FOCUS_CONTEXT_MENU, TRIGGER_AFTER_ORIGINAL, script IG_Trigger_Customer_Maintenance_Context_Menu); if l_result<>SY_NOERR then warning "Focus trigger registration failed."; end if;
The trigger processing procedure adds a command to the context menu that will open the Contact History form. Notice how the script retrieves the tag of the context menu command list, and then adds the command to the end of the list.
{Name: IG_Trigger_Customer_Maintenance_Context_Menu} local integer result; local integer command_tag; local integer context_menu_command_list; {Get the tag for the context menu} context_menu_command_list = Command_GetTag(command cmdListContextMenu); {Add a separator, if needed, in case there are other commands already in the context menu} if CommandList_NumCommands(context_menu_command_list) > 0 then command_tag = Command_GetTag(command cmdSeparator); result = CommandList_Add(context_menu_command_list, command_tag); end if; {Add the command to display the Contact History} command_tag = Command_GetTag(command IG_ContactHistory_ContextMenu of form Command_IG_Sample); result = CommandList_Add(context_menu_command_list, command_tag);