Skip to content
Jincux edited this page Apr 20, 2012 · 2 revisions

Objects

All object that are to be sent to the clients via Glass must be registered first. Any custom profile or GUI used are to be sent. To register any object, use the following:

BLG_GDS.registerObject(NameOfMyObjectHere);

The above function will find any child object of the inputted object, then automatically registers those too.

All objects are managed by what is called a DataObject. This object is the gateway between your add-on and the client. Getting the DataObject of an object is as simple as this:

BLG_GDS.getDataObject(NameOfMyObject);

Modifying Objects

Now that we've registered our objects. Throughout this entire tutorial, I'll be using TestGui as our GUI, TestWindow as a window parented by the TestGui, and TestList, TestText, and TestButton as objects parented by the Window.

Open/Close

First, we want to know how to open our magnificently built GUI.

BLG_GDS.getDataObject(TestGui).push(%client);

%client - The client to open the GUI upon

After you get bored of staring at your GUI, you can also close it.

BLG_GDS.getDataObject(TestGui).pop(%client);

%client - The client to close the GUI upon

Changing Properties

Now that we have our GUI opening and closing, we should be able to making it dynamic and changing! Lets set the text of TestText to "It works!".

BLG_GDS.getDataObject(TestText).setValue("It works!");

Great, we can now change the value. But what about moving it around or resizing it? Lets move it to the position of 100 100

BLG_GDS.getDataObject(TestText).updateAttribute(%client, "position", "100 100");

Interactive Callbacks

You may notice that the "X" button on the your GUI no longer works, even though we set it to close the GUI when we made it. This is because, to ensure safety, BLG has blocked out command, altCommand, and closeCommand. But no worries, we get notified instead now!

To make TestGui close when the "X" button is pressed, do the following:

BLG_GDS.getDataObject(TestWindow).registerCloseHandler("CloseTestGuiHandle");
function CloseTestGuiHandle(%client, %dataObject) {
     BLG_GDS.getDataObject(TestGui).pop(%client);
}

There! We now have a closing GUI. Similar functions:

BLG_GDS.getDataObject(MyButton).registerHandler("MyHandleFunction");
BLG_GDS.getDataObject(MyInput).registerAltHandler("MyAltHandleFunction");