IPrxUserButtonElement.UserButton

Syntax

UserButton: IPrxUserButton;

Description

The UserButton property determines a custom button, to which a toolbar element corresponds.

Example

To execute the example the repository must contain a regular report with the REPORT identifier. The toolbar can be changed, and custom buttons can be created in the report.

Add links to the Metabase, Report system assemblies.

Sub UserProc;
Var
    Mb: IMetabase;
    Report: IPrxReport;
    Toolbar: IPrxToolbar;
Begin
    Mb := MetabaseClass.Active;
    // Get regular report
    Report := Mb.ItemById("REPORT").Bind As IPrxReport;
    // Get toolbar
    Toolbar := Report.Toolbar;
    Debug.WriteLine("Changes on the toolbar: " + Toolbar.IsCustom.ToString);
    // View information about elements
    ShowElements(Toolbar.Elements);
End Sub UserProc;

Sub ShowElements(Elements: IPrxToolbarElements);
Var
    Element: IPrxToolbarElement;
    UserButton: IPrxUserButton;
Begin
    For Each Element In Elements Do
        If Element.Type = PrxToolbarElementType.UserButton Then
            UserButton := (Element As IPrxUserButtonElement).UserButton;
            Debug.WriteLine("Custom button: " + UserButton.Name + '(' + UserButton.Id + ')');
            Debug.Indent;
            Debug.WriteLine("Button type: " + UserButton.Type.ToString);
            Select Case UserButton.Type
                Case PrxUserButtonType.Method:
                    Debug.WriteLine("Fore method: " + (UserButton.Action As IPrxUserButtonActionMethod).ForeMethod);
                    Debug.WriteLine("JS function: " + (UserButton.Action As IPrxUserButtonActionMethod).JsFunction);
                Case PrxUserButtonType.Algorithm:
                    Debug.WriteLine("Started algorithm: " + (UserButton.Action As IPrxUserButtonActionAlgorithm).Algorithm.Name);
                Case PrxUserButtonType.OpenObject:
                    Debug.WriteLine("Opened object: " + (UserButton.Action As IPrxUserButtonActionOpenObject).ObjectForOpen.Name);
            End Select;
            Debug.Unindent;
        Elseif Element.Type = PrxToolbarElementType.UserGroup Then
            ShowElements((Element As IPrxUserGroupElement).Elements);
        End If;
    End For;
End Sub ShowElements;

After executing the example the development environment console displays information about custom buttons in the specified report toolbar.

See also:

IPrxUserButtonElement