Kbase P50754: ADM2 How to know which instance of a SmartToolbar generated
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  13/11/2003 |
|
Status: Unverified
GOAL:
ADM2 How to know which instance of a SmartToolbar generated an event.
FIX:
When using multiple SmartToolbars in the same container, you may wish to know which toolbar generated which event.
If a custom button is added via actioncustom.p, the source-procedure will always be reported as toolbar.p because that is where the initial event trigger procedure for the button is located.
To identify which instance of the SmartToolbar contains the button generating the event, one can identify the button with the SELF system handle, walk up to the widget tree to find the frame containing the button, and compare this to the PanelFrame property of the different toolbar instances.
For example:
PROCEDURE doSomething:
DEFINE VARIABLE f AS HANDLE NO-UNDO.
DEFINE VARIABLE tb1 AS HANDLE NO-UNDO.
DEFINE VARIABLE tb2 AS HANDLE NO-UNDO.
ASSIGN f = SELF:PARENT:PARENT /* Button - field group - parent frame */
tb1 = DYNAMIC-FUNCTION('getPanelFrame':U IN h_dyntoolbar)
tb2 = DYNAMIC-FUNCTION('getPanelFrame':U IN h_dyntoolbar-2).
CASE f:
WHEN tb1 THEN
MESSAGE "doSomething called from toolbar 1".
WHEN tb2 THEN
MESSAGE "doSomething called from toolbar 2".
OTHERWISE
MESSAGE "doSomething not called from recognized SmartToolbar".
END CASE.
END PROCEDURE.
note: This code assumes the procedure doSomething is in the container containing the SmartToolbars. Depending on application design, additional logic may be required to obtain the procedure handles of the SmartToolbar instances.