Kbase P105350: How to subscribe to an event published by a Treeview toolbar?
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  07/12/2006 |
|
Status: Unverified
GOAL:
How to subscribe to an event published by a Treeview toolbar?
GOAL:
How to get the handle of a Treeview toolbar and respond to events that it publishes?
FACT(s) (Environment):
Dynamics
FIX:
By default the Treeview container has an objcTop toolbar. In the Toolbar and Menu designer a button is added to this toolbar with an item to PUBLISH an action called "EV1". The Item link for this action is "containertoolbar-target".
The treeview has an associated super procedure and a dynamic viewer to display the node details. The viewer also has its own super procedure.
In the viewer super procedure a procedure is created called "EV1" that simply displays the message "ViewerSupr - EV1".
In an InitializeObject procedure override of the viewer super procedure add the following code after RUN SUPER:
DEFINE VARIABLE hContainer AS HANDLE NO-UNDO.
DEFINE VARIABLE hSource AS HANDLE NO-UNDO.
DEFINE VARIABLE cTHndl AS CHARACTER NO-UNDO.
DEFINE VARIABLE h AS HANDLE NO-UNDO.
DEFINE VARIABLE i AS INTEGER NO-UNDO.
{get ContainerSource hContainer TARGET-PROCEDURE}. /* hContainer = frame */
{get ContainerSource hSource hContainer}. /* hSource = window */
{get ContainerTarget cTHndl hSource}.
DO i = 1 TO NUM-ENTRIES(cTHndl):
h = WIDGET-HANDLE(ENTRY(i, cTHndl)).
MESSAGE h h:TYPE h:FILE-NAME
VIEW-AS ALERT-BOX INFO BUTTONS OK.
IF h:FILE-NAME = "ry/obj/rydyntoolt.w" THEN
SUBSCRIBE PROCEDURE TARGET-PROCEDURE TO "EV1" IN h.
END.
This subscribes the viewer to the objcTop EV1 event.
Now run the treeview and select a node so that the viewer is initialized, then select the button on the toolbar, the EV1 procedure is run and displays the expected message. If multiple instances of the container are run from the dynamic launcher there will be only a single message displayed when the toolbar button is selected. This is because the viewer is only subscribed to its particular Treeview toolbar and no other toolbar.
In the above code instead of testing the file-name attribute, the getObjectName or getObjectType functions could be used instead.