How do set drawing from Glg Object

21 views
Skip to first unread message

nvd...@gmail.com

unread,
Apr 1, 2020, 3:56:06 AM4/1/20
to GLG Toolkit Community Edition
I had used glg api C# befored.

In glg api C# 3.8 have a function as : SetDrawingObject( GlgObject ) to set a glgobject to display.

Now, I using javascript API. How function in javascript allow me can do this.

Thanks for support !
Message has been deleted

glg_devel

unread,
Apr 2, 2020, 12:18:55 PM4/2/20
to GLG Toolkit Community Edition
In C#, GLG drawing is deployed via the GLG C# Control. The SetDrawingObject is a method of the control that assigns the drawing to the parent control that will display the drawing.

There is no equivalent JavaScript Control in the HTML5 environment. Instead, the SetParentElement method of the drawing viewport is used to assign a parent HTML element to the drawing. The drawing will be displayed inside this parent HTML element.

The following is a sequence of calls used in the JavaScript to display a GLG drawing:

1. A GLG drawing is loaded asynchronously using the LoadWidgetFromURL method, specifying the drawing URL and the load callback (LoadCB) to be invoked when the drawing is ready, for example:

    GLG.LoadWidgetFromURL( "mydrawing.g", null, LoadCB, user_data );

2. When the drawing is ready, the LoadCB callback is invoked with an object ID of the loaded drawing viewport. The following methods are invoked inside the callback to display the drawing:

    // Assign a parent HTML element to the drawing.
    drawing.SetParentElement( "glg_area" );

    // Display the drawing.
    drawing.InitialDraw();

Alternatevely, the SetupHierarchy and Update methods may be used instead of InitialDraw:

    // Display the drawing.
    drawing.SetupHierarchy();
    drawing.Update();

The source code at the following link provides an example of using a GLG drawing on a web page:


More source code examples are provided in the examples_html5 directory of the GLG download.

Reply all
Reply to author
Forward
0 new messages