CreateMenu

From GT-MP
Jump to: navigation, search
CreateMenu
Client-Side Function
System-users.png Client-Side Javascript.png JavaScript

Creates a native menu that can be rendered on the screen.


Syntax

API.createMenu(string title, string subtitle, double x, double y, int anchor, bool enableBanner = true);

Required Arguments

  • title: parameter input should be in string type.
  • subtitle: parameter input should be in string type.
  • x: the X offset for the position of the menu as a double. The direction is based on the anchor position.
  • y: the Y offset for the position of the menu as a double. The direction is based on the anchor position.
  • anchor: the anchor point at which the menu will be shown on the screen. 0 is top left, 1 is top middle, 2 is top right, 3 is middle left, 4 is middle, 6 is middle right, 7 is bottom left, 8 is bottom middle, 9 is bottom right (outside of the screen for some reason).


Optional Arguments

  • enableBanner: parameter input should be in bool type. This enables or disables the banner header containing the title text. (set to true by default)


NOTE: This function returns data in UIMenu type.

Usage example(s)

Dialog-warning.png API.drawMenu() was removed in Version 0.1.638.634, See Deprecated for more information.

In Javascript
Client-Side Function

UIMenu.png
var g_menu = API.createMenu("Banner", "Subtitle", 0, 0, 6);
g_menu.ResetKey(menuControl.Back);

for (var i = 0; i < 20; i++) {
	g_menu.AddItem(API.createMenuItem("Item " + i, "Description " + i));
}

g_menu.OnItemSelect.connect(function(sender, item, index) {
	API.sendChatMessage("You selected: ~g~" + item.Text);

	API.showCursor(false);
	g_menu.Visible = false;
});

API.onServerEventTrigger.connect(function(name, args) {
	if (name == "OPEN_MENU") {
		API.showCursor(true);
		g_menu.Visible = true;
	}
});

References

NativeUI wiki