This page has been translated automatically.
UnigineScript
The Language
Core Library
Engine Library
Node-Related Classes
Plugins Library
High-Level Systems
Samples
Usage Examples
C++ API
API Reference
Integration Samples
Usage Examples
C++ Plugins
Migration
Migrating to UNIGINE 2.0
C++ API Migration
Migrating from UNIGINE 2.0 to UNIGINE 2.1
Внимание! Эта версия документация УСТАРЕЛА, поскольку относится к более ранней версии SDK! Пожалуйста, переключитесь на самую актуальную документацию для последней версии SDK.
Внимание! Эта версия документации описывает устаревшую версию SDK, которая больше не поддерживается! Пожалуйста, обновитесь до последней версии SDK.

WidgetMenuBox Class

This class creates a menu box. It can be either stand-alone or attached to a menu bar. In the first case it needs to be handled manually. By using this widget, you can do the following:

  • Create hierarchical menus.
  • Use the other widgets as menu items (See the example).

See Also

WidgetMenuBox Class

This class inherits from Widget

Members


WidgetMenuBox (Gui gui, int space_x = 0, int space_y = 0)

Constructor. Creates an empty menu box with specified spacing between menu items and items and menu borders.

Arguments

  • Gui gui - GUI, to which the menu will belong.
  • int space_x - Horizontal space.
  • int space_y - Vertical space.

int addItem (string text, int icon = -1)

Adds a new item with a given text and an icon.

Arguments

  • string text - Item text.
  • int icon - Zero-based ID of the icon (i.e. number of the icon in the icon texture).

Return value

Number of the added item.

void clear ()

Removes all items from the menu.

string getCurrentItemData ()

Returns the data of a given item.

Return value

Item data.

string getCurrentItemText ()

Returns the text of the item, which is currently in focus.

Return value

Item text if the item is in range from 0 to the total number of items; otherwise, NULL

int getCurrentItem ()

Returns the item, which is currently in focus.

Return value

Item number.

Image getImage ()

Returns the image with mini-icons.

Return value

Image with mini-icons.

string getItemData (int item)

Returns the data of the currently selected item.

Arguments

  • int item - Item number in range from 0 to the total number of items.

Return value

Item data.

int getItemSpace (int item)

Returns the space between the given menu item and the next item.

Arguments

  • int item - Item number in range from 0 to the total number of items.

Return value

Space between items, in pixels.

string getItemText (int item)

Returns the text of a given item.

Arguments

  • int item - Item number in range from 0 to the total number of items.

Return value

Item text.

int getItemTexture (int item)

Returns the icon of a given item.

Arguments

  • int item - Item number in range from 0 to the total number of items.

Return value

Zero-based ID of the icon (i.e. number of the icon in the icon texture).

string getItemToolTip (int item)

Returns a tooltip of a given item.

Arguments

  • int item - Item number in range from 0 to the total number of items.

Return value

Item tooptip.

Widget getItemWidget (int item)

Returns a widget set for the given item of the menu.

Arguments

  • int item - Item number on range from 0 to the total number of menu items.

Return value

A widget used as an item.

int getNumItems ()

Returns the number of items in the menu.

Return value

Number of items.

int getSpaceX ()

Returns the horizontal space between menu items and between them and menu borders.

Return value

Horizontal space.

int getSpaceY ()

Returns the vertical space between menu items and between them and menu borders.

Return value

Vertical space.

string getTexture ()

Returns file name of the image with mini-icons.

Return value

Path to the texture file.

int isItemEnabled (int item)

Returns a value indicating if a given item is enabled (i.e. you can interact with this item).

Arguments

  • int item - Item number.

Return value

1 if the item is enabled; otherwise, 0.

int isItemSelectable (int item)

Returns a value indicating if the given item can be selected (i.e. the item is highlighted when you point to it). By default, the item is selectable.

Arguments

  • int item - Item number.

Return value

1 if the item can be selected; otherwise, 0.

int isItemSeparator (int item)

Checks whether a separator is placed after the given item.

Arguments

  • int item - Item number in range from 0 to the total number of items.

Return value

Positive number if separator is placed; otherwise, 0.

void removeItem (int item)

Removes a given item from the menu.

Arguments

  • int item - Item number in range from 0 to the total number of items.

void setImage (Image image)

Sets an image with mini-icons to be used with items. The image is a vertical strip of square icons.

Arguments

  • Image image - Image to set.

void setItemData (int item, string data)

Sets the data for a given item. The data can be used as a text identifier of the item (instead of using the number of the item).

Arguments

  • int item - Item number in range from 0 to the total number of items.
  • string data - Data to set.

void setItemEnabled (int item, int mode)

Sets a value indicating if a given item is enabled (i.e. you can interact with this item).

Arguments

  • int item - Item number in range from 0 to the total number of items.
  • int mode - 1 to enable the item, 0 to disable it.

void setItemSelectable (int item, int selectable)

Sets a value indicating if a given item can be selected (i.e. the item is highlighted when you point to it).

Arguments

  • int item - Item number in range from 0 to the total number of items.
  • int selectable - 1 to set the item as selectable; otherwise, 0.

void setItemSeparator (int item, int separator)

Adds or removes a separator after a given item.

Arguments

  • int item - Item number in range from 0 to the total number of items.
  • int separator - Positive number to add a separator, 0 to remove it.

void setItemSpace (int item, int space)

Sets a space between the given menu item and the next item.

Arguments

  • int item - Item number in range from 0 to the total number of menu bar items.
  • int space - Space to set, in pixels.

void setItemText (int item, string text)

Sets a text for a given item.

Arguments

  • int item - Item number in range from 0 to the total number of items.
  • string text - Item text.

void setItemTexture (int item, int icon)

Sets an icon for a given item.

Arguments

  • int item - Item number in range from 0 to the total number of items.
  • int icon - Zero-based ID of the icon (i.e. number of the icon in the icon texture).

void setItemToolTip (int item, string tooltip)

Sets a new tooltip for the given item.

Arguments

  • int item - Item number in range from 0 to the total number of items.
  • string tooltip - Tooltip to set.

void setItemWidget (int item, Widget widget)

Sets a widget for the given item of the menu.

Arguments

  • int item - Item number in range from 0 to the total number of items.
  • Widget widget - A widget to be used as a menu item.

Examples

Source code (UnigineScript)
WidgetMenuBox menubox;

Gui gui	= engine.getGui();
menubox = new WidgetMenuBox(gui);
menubox.addItem("Item 0");
menubox.addItem("Item 1");
menubox.setItemWidget(menubox.addItem(NULL),new WidgetButton(gui,"Button"));
The example produces the following result:

void setSpace (int space_x, int space_y)

Sets a space between menu items and between them and menu borders.

Arguments

  • int space_x - Horizontal space. If a negative value is provided, 0 will be used instead.
  • int space_y - Vertical space. If a negative value is provided, 0 will be used instead.

void setTexture (string texture)

Sets a texture with mini-icons to be used with items. The texture is a vertical strip of square icons.

Arguments

  • string texture - Path to a texture file.
Last update: 03.07.2017
Build: ()