MyGUI widget control        
Print

Create

Manually

To create a widget without a parent:

MyGUI::Gui::getInstance().createWidget<MyGUI::widget_type>("skin_name", x, y, w, h, MyGUI::Align, "layer_name"[, "widget_name"]);

MyGUI::Gui::getInstance().createWidgetReal<MyGUI::widget_type>("skin_name", x_r, y_r, w_r, h_r, MyGUI::Align, "layer_name"[, "widget_name"]);

 
To create a child widget:

parent_ptr->createWidget<MyGUI::widget_type>("skin_name", x, y, w, h, MyGUI::Align [, "widget_name"]);
parent_ptr->createWidgetReal<MyGUI::widget_type>("skin_name", x_r, y_r, w_r, h_r, MyGUI::Align [, "widget_name"]);

 
Possible widget_type values can be found at the MyGUI main page.

skin_name can be the same as the widget or any skin from the MyGUI main page.

x, y, w, h is the widget position, width, and height in pixels.

x_r, y_r, w_r, h_r is the widget position width and height relative to its parent (or the screen, if it doesn't have a parent) in coordinates from 0 to 1.

Possible align values can be found in the align table.

All layer_names can be found in the standard layers.

widget_name is an optional parameter.

Find

To find a widget (for example a Button)

MyGUI::Button* button = MyGUI::Gui::getInstance().findWidget<MyGUI::Button>("button_name");

If you don't care about the widget type, you can write:

MyGUI::Widget* any_widget = MyGUI::Gui::getInstance().findWidgetT("widget_name");

 

Destroy

To destroy widgets you need to have pointers to them of the form (widget_ptr). Then write

MyGUI::Gui::getInstance().destroyWidget(widget_ptr);

If you don't have a pointer to your widget, you should get it by searching for it by name.

MyGUI::Widget* widget = MyGUI::Gui::getInstance().findWidgetT("widget_name");

MyGUI::Gui::getInstance().destroyWidget(widget);

 


Contributors to this page: Datalore87 points  , jacmoe133512 points  , Beauty10198 points  and Altren595 points  .
Page last modified on Saturday 25 of February, 2012 00:00:29 UTC by Datalore87 points .


The content on this page is licensed under the terms of the Creative Commons Attribution-ShareAlike License.
As an exception, any source code contributed within the content is released into the Public Domain.