Class: Item

Item(text, oParent, nPosition)

new Item(text, oParent, nPosition)

The Item class defines the item within the Menu control
Parameters:
Name Type Description
text string | object Indicates a string represemtation that defines the sub-items, such as "Item 1,Item 2,[sep],Check 1[chk],Check 2[chk]" or an object of {caption,flags,subText} type
oParent Item Specifies an object of Item type that defines the item's parent. If null/missing/undefined it means the root item.
nPosition number Specifies the position within the parent's child collection. If null/missing/undefined the new elements are added to the end

Members

(static) AutoID

Indicates the counter to specify a different ID for each item (Item)

(static, readonly) PartEnum :string

The Item.PartEnum type defines the parts of the Item object (Item.PartEnum)
Type:
  • string
Properties:
Name Type Description
exItem string The exItem field specifies the item's client part (it includes all parts of the item as check, image, caption, popup arrow and sub-items)
exFlat string The exFlat field specifies the portion of the menu to show the flat bar
exCheck string The exCheck field indicates the item's check-box part.
exRadio string The exRadio field indicates the item's radio-button part.
exImage string The exImage field indicates the item's image/icon part.
exCaption string The exCaption field indicates the item's caption part.
exButton string The exButton field indicates the item's button part.
exButtonRArrow string The exButtonRArrow field indicates the item's button-select part (shown to the right).
exButtonBArrow string The exButtonBArrow field indicates the item's button-select part (shown to the bottom).
exSeparator string The exSeparator field indicates the item's separator part.
exArrow string The exArrow field indicates the item's arrow part.
exSubItems string The exSubItems field indicates the item's sub-items part.
exMenu string The exMenu field indicates the entire menu

caption :string

Defines the item's caption. The caption property supports ex-HTML format.
Type:
  • string

flags :map

Defines the item's flags as map of [name => value] type that specifies the options of the current item
Type:
  • map

(readonly) id :any

Specifies the item's identifier. The id property gets the identifier as specified by [id] flag, while getID() method gets the item's identifier no matter if it was specified by [id] flag. You can use the Debug property of the Menu object to display identifiers for all items within the menu.
Type:
  • any

Methods

forEachU(callback, thisArg) → {any}

The forEachU() method enumerates recursivelly the child-items, until the callback returns a truly value
Parameters:
Name Type Description
callback callback Specifies a function of callback(oItem) {any} type that's invoked for each item. The arguments of the callback are:
oItem {Item}, specifies the item of Item type
thisArg any Indicates the value of "this" keyword during the callback (if not specified it refers the current object as an Menu type)
Returns:
Returns the last-result of callback(oItem) call
Type
any

getID() → {number}

The getID() method gets the item's identifier
Returns:
Returns the item's identifier.
Type
number

getParent() → {Item}

The getParent() method gets the item's parent. The getParent() method and parent property are equivalents. The getRoot()/root returns the root item (the root item has no parent item)
Since:
  • 1.1
Returns:
Returns the item's parent as an object of Item type
Type
Item
Example
oItem.parent.caption {string}, returns the caption of the parent item

getPath() → {Array.<any>}

The getPath() method gets the path of the current item (it includes all identifiers for each parent to the root). The getPath() method and path property are equivalents.
Returns:
Returns an array of [number] type that specifies the path of the current item.
Type
Array.<any>

getPathID() → {any}

The getPathID() method returns the item's identifier to build/search for a path
Returns:
A string expression that specifies the item's path identifier.
Type
any

getRoot() → {Item}

The getRoot() method returns the root item (the root item has no parent). The getRoot() method and root property are equivalents. The getRoot()/root includes all items of the menu. The getParent()/parent property returns the item's parent.
Returns:
Returns an object of Item type that specifies the root item.
Type
Item
Example
console.log(oMenu.Item("File").root.save()), displays the entire menu in string representation
 oMenu.Item("File").root.forEachU(function(oItem) { console.log(oItem.caption) }), enumerates all items within the menu

getState() → {number}

The getState() method indicates the state of the current item. The getState() / state property are equivalents.
Returns:
Returns 0 for unchecked, or 1 for a checked item
Type
number

hasImage() → {string}

The hasImage() method gets the image of the item. The hasImage() method / image property are equivalents.
Returns:
Returns the item's image or null if no image is associated with the item
Type
string

hasItems() → {boolean}

The hasItems() method specifies whether the item has child-items.
Returns:
Returns true if the item contains children
Type
boolean

isEnabled() → {boolean}

The isEnabled() method indicates whether the item is enabled or disabled (it checks also the parent items). The isEnabled() method / enabled property are equivalents.
Returns:
Returns true if the item is enabled (including all its predecessors).
Type
boolean

isVisible() → {boolean}

The isVisible() method specifies whether the item is visible or hidden. The isVisible() method and visible property are equivalents.
Returns:
Returns true if the current item is visible
Type
boolean

load(text)

The load() method loads the items from a string representation (ToString format). The load() method overrides the current item, and may insert new items on the same level.
Parameters:
Name Type Description
text string Indicates a string represemtation that defines the items, such as "Item 1,Item 2,[sep],Check 1[chk],Check 2[chk]". If empty/null/undefined the current element is removed, else it is replaced

save() → {string}

The save() method returns the current item as a string representation (ToString format)
Returns:
Returns the string representation of the current item (including its children), such as "Item[group=0x01](Child 1,Child 2[dis],Child 3)"
Type
string

setEnabled(value)

The setEnabled() method enables or disables the item. The setEnabled() method / enabled property are equivalents.
Parameters:
Name Type Description
value boolean Indicates whether the item is enabled or disabled
Since:
  • 1.1

setImage(value)

The setImage() method sets the image of the item. The setImage() method / image property are equivalents.
Parameters:
Name Type Description
value string Specifies the item's image or null/undefined/empty if no image is associated with the item
Since:
  • 1.1

setState(value)

The setState() method changes the item's check/radio state (changes the "chk" or "rad" flags) The getState() / state property are equivalents.
Parameters:
Name Type Description
value number Specifies the item's new state (0 or not-zero)

setVisible(value)

The setVisible() method shows or hides the item. The setVisible() method and visible property are equivalents.
Parameters:
Name Type Description
value boolean Specifies whether the item is visible or hidden
Since:
  • 1.1

toString() → {string}

The toString() method convert the item to a string whenever the item is used in a string context
Returns:
Returns the item’s string representation
Type
string