The user can create a new sibling item in any polygon. To do this, the addNewSibling method should be used. The parameters here are as follows:
The new sibling item will be inserted right after the item chosen as "nextToId" one.
myMenu.addNewSibling(nextToId, ItemId, itemText, disabled, img,imgDis);
There is the possibility to create a child item for any item in the menu. The child item will be located in a sub-level polygon and won't be visible until its parent item is hovered over. The addNewChild method should be called and the following parameters are to be passed:
myMenu.addNewChild(parentId, position, itemId, itemText, disabled, img, imgDis);
The user can choose to remove any item from a menu. The item will be removed with all its sub-items/sub-polygons. An item can be removed in the following way:
myMenu.removeItem(Id);
Related sample: Add / remove items
Separators can be created with the help of addNewSeparator method. A separator provides kind of a logical grouping of menu items. The addNewSeparator method has the following parameters:
myMenu.addNewSeparator(nextToId, itemId);
There is the possibility to get parent id of any menu item. This can be done by passing the item's id to the getParentId method:
var parentId = myMenu.getParentId(id);
Any menu item can be enabled/disabled by user:
myMenu.setItemEnabled(id);
myMenu.setItemDisabled(id);
Also the user has the possibility to check whether an item is enabled. This can be done by calling the following method:
var isEnabled = myMenu.isItemEnabled(id); // returns true|false
The user should pass id of the item that will be checked. The method returns true if the item is enabled.
Related sample: Enable / disable items
Any item in a menu can be shown/hidden. To do this, the user should pass this item's id to the following methods:
myMenu.showItem(id);
myMenu.hideItem(id);
The user has the possibility to check whether an item is hidden, by passing the item's id to the isItemHidden method. The method returns true, if the item is hidden:
var isHidden = myMenu.isItemHidden(id);
Related sample: Show / hide items
The user can set text for any menu item. This item's id and text are passed as parameters to the following method:
myMenu.setItemText(id, text);
The user can get item's text using getItemText method. The method returns the current text of the item:
var text = myMenu.getItemText(id); // returns item's text
Related sample: Change items text
Item's position in the polygon can be set by applying the method setItemPosition and passing item's id and item's position number (starting with 0) as parameters:
myMenu.setItemPosition(id,pos);
There is the possibility to get items' position. The method returns item's position number:
var pos = myMenu.getItemPosition(id); // returns item's position
Related sample: Change items position
The user has the possibility to set, store, and pass values set for a certain menu item. One menu item can have several different user data stored in it. User data can be set to any menu item. The user just needs to pass this item's id, name of the data and its value to the setUserData method:
myMenu.setUserData(id, name, value);
An easy way to get user data is to use getUserData method by passing the item's id and data name to it:
var value = myMenu.getUserData(id, name);
Related sample: Change items userdata
Any item in a menu can have its own image displayed in the left part of item display area. The setItemImage method allows the user to set image to an item by passing the following parameters:
myMenu.setItemImage(id,img,imgDis);
The getItemImage method gets current item images for enabled and disabled states and returns array(img, imgDis) that will contain URLs to images:
var imgs = myMenu.getItemImage(id); // returns array
Item's image can be easily removed/cleared by using the clearItemImage method to which the user should pass item's id:
myMenu.clearItemImage(id);
Related sample: Change items images
The user can specify the supplementary information regarding the item - tooltip. The setTooltip method takes the following parameters:
myMenu.setTooltip(id,tip);
The following method can return current item's tooltip text:
var tip = myMenu.getTooltip(id);
Hotkey is a shortcut to a menu option. In our menu it's just a label (text) written in the item display area.
A hotkey can be set to any menu item by calling setHotKey method and passing item's id and setting the hotkey label:
myMenu.setHotKey(id, hkey);
The getHotKey method returns current item's hotkey text:
var hkey = myMenu.getHotKey(id); // returns hotkey text
An item of this type has a small, square box (in the left part of item display area) in addition to item's title. Any other icons can't be added to this type of items.
This item can be created by calling addCheckbox method that takes the following parameters:
myMenu.addCheckbox(mode, nextToId, pos, itemId, itemText, state, disabled);
New state (checked/unchecked) of the checkbox can be set by the following method:
myMenu.setCheckboxState(id,state);
A simple way to get the current state of a checkbox is presented below:
var state = menu.getCheckboxState(id); // returns true|false
Item of this type has a small selectable circle (in the left part of item display area) in addition to item's title. Any other icons can't be added to this type of items.
This item can be created by calling the addRadioButton method that takes the following parameters:
myMenu.addRadioButton(mode, nextToId, pos, itemId, itemText, group, state, disabled);
Any unchecked radio button can be made checked while currently checked radio button automatically changes its state to unchecked:
myMenu.setRadioChecked(id,state);
An easy way to get id of the current checked radio button in a radio group is presented below:
var idChecked = myMenu.getRadioChecked(group);
Related sample: Checkboxes and radio buttons
Back to top