FixGUI Documentation

Back to summary

import "gui/view";

Menu class

This class is used for both main menu and popup menus.

Initialization

static function create(): Menu
Creates a new menu.

Properties

function insert_item(idx: Integer, title: String, action, data, id: Integer)
function insert_separator(idx: Integer)
function insert_submenu(idx: Integer, title: String, submenu: Menu)
function insert_item(idx: Integer, item: MenuItem)
Inserts a menu item at the given index (use -1 to insert at end). The item can be either a regular item with attached callback, a separator, a submenu, or a menu item object. The callback is taking two parameters, first is data and second is id.
function add_item(title: String, action, data, id: Integer)
function add_separator()
function add_submenu(title: String, submenu: Menu)
function add_item(item: MenuItem)
Adds a menu item at the end. This is just a shortcut for inserting with the index set to -1.
function remove_item(idx: Integer)
Removes a menu item at given index.
function get_item_count(): Integer
Returns the menu item count in this menu.
function get_item(idx: Integer): MenuItem
Returns the menu item object at given index.
function dump()
Dumps the hierarchy of the menu to the logging channel of the application.

Actions

function show(view: View or SubView, x: Integer, y: Integer)
Shows the popup menu at given position in a view or a subview.

This class contains information about the menu item. It is just a container of information not a native handle.

Fields

var menu: Menu;
The menu this item belongs to.
var idx: Integer;
The index in the menu.
var title: String;
The title of the menu item.
var submenu: Menu;
The submenu.
var action;
var data;
var id: Integer;
The callback data.

Methods

function is_separator(): Boolean
Returns true when this menu item is a separator.
function update()
Updates the menu item. This is done by using the index therefore beware of updating of wrong menu items if the order of items is changed in the menu.
function to_string(): String
Returns the string representation of the menu item.