vegui. menu. class.js

Summary
vegUI element type for VegUIMenu
vegUI element type for VegUIMenuItem
The popup menu widget.
extends VegUINode
These child elements are all accessable over *this.[child_name] even though they may not all be direct children of this element
These flags are enabled by default for this element
When an item is added via the add_item method then it will also be added to the Items property of the menu.
Constructor
Adds an item to the menu
Befriends several menues, making sure only one of them can be open at the same time
Builds the menu
Close this menu and all open sub menues
Closes all friend menues
Closes all child menues
Clears the menu of all items
Best function name EVER
Starts a timer that will close the menu in this.<closeTime> ms.
Checks if this or any of the child menues of this menu is active
Links another VegUIMenu element as a subment to this menu.
Shows the menu.
Sets the most common template properties of this menu
An item in VegUIMenu object
extends VegUIButton
These flags are turned on for this element by default
constructor
Builds the menu item
Sets the most common template properties for the menu item

Constants

VUI_MENU

vegUI element type for VegUIMenu

VUI_MENU_ITEM

vegUI element type for VegUIMenuItem

VegUIMenu

The popup menu widget.

Summary
extends VegUINode
These child elements are all accessable over *this.[child_name] even though they may not all be direct children of this element
These flags are enabled by default for this element
When an item is added via the add_item method then it will also be added to the Items property of the menu.
Constructor
Adds an item to the menu
Befriends several menues, making sure only one of them can be open at the same time
Builds the menu
Close this menu and all open sub menues
Closes all friend menues
Closes all child menues
Clears the menu of all items
Best function name EVER
Starts a timer that will close the menu in this.<closeTime> ms.
Checks if this or any of the child menues of this menu is active
Links another VegUIMenu element as a subment to this menu.
Shows the menu.
Sets the most common template properties of this menu

Hierarchy

extends VegUINode

Inherits all properties and methods from VegUINode

VegUINode
|
+-- VegUIMenu

Dependencies

Child Elements

These child elements are all accessable over *this.[child_name] even though they may not all be direct children of this element

SkinVegUINode, the skin node of the menu
TableVegUINode, the table that holds the items
TbodyVegUINode, controlls the tbody node in the table
TRowVegUIMenuItem, Template row, all rows added will be cloned from this template

Flags

These flags are enabled by default for this element

VUI_HMOUSE_OUT | VUI_HMOUSE_OVER

Item Index Explanation

When an item is added via the add_item method then it will also be added to the Items property of the menu.

myMenu.add_item('item 1'); // index 0
myMenu.add_item('item 2'); // index 1
myMenu.add_item('item 3'); // index 2

So item1 could be accessed by myMenu.Items[0]

Properties

Object Properties

ItemsArray , holds the VegUIMenuItem objects in this menu
RootMenuVegUIMenu, holds a pointer to the root menu of this menu
ParentMenuVegUIMenu, holds a pointer to the parent menu of this menu
ChildMenuArray, holds all the sub menues of this menu
FriendMenuArray, holds all the befriended menues of this menu
closeTimeint, time it takes before the menu is closed after the mouse cursor has left it
arrowImgstring, path of the image to use for the arrow that indicates a nested menu
nestedSpaceint, space between this menu and its child menu
fxNoFadebool, if true there will be no fade effects even if init_fx was called on the manager
fxFadeTimeint, time of fade effect (ms)
fxFadeLimitInint, limit of fade in effect, if set the fade effect will be halted at the selected value (0-100)
noCorrectionbool if true the menu will be allowed to go outside of the manager node’s proportions.  If false (default) then it will auto correct it’s position on popup should it be positioned outside of the manager’s borders.

Template Properties

T.closeTimecloseTime
T.arrowImgarrowImg
T.nestedSpacenestedSpace
T.noCorrectionnoCorrection
T.fxNoFadefxNoFade
T.fxFadeLimitInfxFadeLimitIn
T.fxFadeTimefxFadeTime

Functions

VegUIMenu

function VegUIMenu(refName,
Parent,
Manager)

Constructor

See Parent

VegUINode::VegUINode

add_item

this.add_item = function(content,
script,
lIcon)

Adds an item to the menu

Parameters

string contenttext of the item
<function script>function to execute when the item is clicked
string lIconpath of the image that is to be displayed on the left side of the item

Returns

VegUIMenuItemreturns the created item

See also

flush

Example

Menu.add_item('Item Description', function() { alert('clicked'); }, 'icon.gif');

befriend

this.befriend = function(FMArr,
noSpread)

Befriends several menues, making sure only one of them can be open at the same time

Parameters

Array FMArrarray holding menues to be friend, this array also needs to hold a pointer to this menu for it to work correctly

Note

The befriend method only needs to be called on one menu, it will call the befriend method on the other menues automatically

See also

close_friends

Example

// Menu1 will automatically be closed if Menu2 is opened and
// vice versa

Menu1.befriend([Menu1,Menu2]);

build_menu

this.build = this.build_menu = function(toNode)

Builds the menu

private function

You should always use VegUIManager::build_element to build VegUI elements

Alias

build()

Parameters

<HTMLNode toNode>if submitted the created HTML node will be appended to toNode

Returns

nullon failure
int1 on success

See Parent

VegUINode::build_node

close

this.close = function()

Close this menu and all open sub menues

See also

init_close, popup

close_friends

this.close_friends = function()

Closes all friend menues

See also

close_children, befriend

close_children

this.close_children = function()

Closes all child menues

See also

close_friends, popup

flush

this.flush = function()

Clears the menu of all items

See also

add_item

get_open

this.get_open = function()

Returns

VegUIMenuthe child menu (sub menu) that is currently open for this menu
nullif no child menu is open

See also

get_tail

get_tail

this.get_tail = function()

Best function name EVER

Returns

VegUIMenuThe child menu on the end of the open child menu chain
VegUIMenuthis, if no child menues are open

init_close

this.init_close = function()

Starts a timer that will close the menu in this.<closeTime> ms. If the mouse enters the menu before the timer has run out the process is interrupted.

See also

close, popup

is_active

this.is_active = function()

Checks if this or any of the child menues of this menu is active

link_menu

this.link_menu = function(itemIdx,
Menu)

Links another VegUIMenu element as a subment to this menu.  If the mouse hovers over the item that links to the submenu it is opened.

Parameters

int itemIdxitem index of the item that shall link to the sub menu.  Item Index Explanation
VegUIMenu Menuthe menu that shall be the submenu

See also

befriend

Example

// add item to the menu, this example is assuming that the
// menu has no other items in it yet

Menu.add_item('Item 1');

// Link Menu2 to 'Item 1' in Menu, so it will be opened
// as a sub menu when the user hovers over 'Item 1' in
// Menu

Menu.link_menu(0, Menu2);

popup

this.popup = function(x,
y)

Shows the menu.  If coordinates are submitted the menu will be moved to those coordinates first.  If no coordinates are submitted and the manu is a submenu of another menu then it will be moved to be besides the menu item that links to it.

Parameters

<int x>x position (pixels)
<int y>y position (pixels)

See also

close, init_close

set_menu

this.set = this.set_menu = function(x,
y,
w,
closeTime,
cN,
arrowImg,
nSpace)

Sets the most common template properties of this menu

Alias

set()

Parameters

int xx position (pixels)
int yy position (pixels)
int wwidth (pixels)
int closeTimethe time it takes for the menu to close after the mouse cursor has left it (ms)
string cNCss class to use for the menu
string arrowImgpath of the image to use for the icon that indicates a sub menu
int nSpacespace between a parent menu and a submenu

See Parent

VegUINode::set_node

VegUIMenuItem

An item in VegUIMenu object

Summary
extends VegUIButton
These flags are turned on for this element by default
constructor
Builds the menu item
Sets the most common template properties for the menu item

Hierarchy

extends VegUIButton

Inherits all properties and methods from VegUIButton

VegUINode
|
+-- VegUIButton
|
+-- VegUIMenuItem

Dependencies

Child Elements

LCellVegUINode, left cell, holds left icon
MCellVegUINode, middle cell, holds item text
RCellVegUINode, right cell, holds right icon

Flags

These flags are turned on for this element by default

VUI_HMOUSE_OUT | VUI_HMOUSE_OVER

Properties

Template Properties

T.labelstring, text of the item
T.rIconImgstring, path of the right icon image
T.lIconImgstring, path of the left icon image
T.lIconWint, width of the left cell
T.rIconWint, width of the right cell

Functions

VegUIMenuItem

function VegUIMenuItem(refName,
Parent,
Manager)

constructor

See Parent

VegUIButton::VegUIButton

build_mnuitem

this.build = this.build_mnuitem = function(toNode)

Builds the menu item

Alias

build()

Parameters

<HTMLNode toNode>if submitted the created html node will be appended to toNode

Returns

nullon failure
int1 on success

See Parent

VegUIButton::build_button, VegUINode::build_node

set_mnuitem

this.set = this.set_mnuitem = function(content,
script,
lIcon,
rIcon,
h,
lIconW,
rIconW,
nClass,
hClass)

Sets the most common template properties for the menu item

Alias

set()

Parameters

string contenttext of the item
function scriptscript to be executed when the item is clicked
string lIconpath of the image to use for the left icon graphic
string rIconpath of the image to use for the right icon graphic
int hheight (pixels)
int lIconWwidth of the left cell (pixels)
int rIconWwidth of the right cell (pixels)
string nClassCSS class to use for item when mouse is not touching it
string hClassCSS class to use for item when mouse is touching it

See Parent

VegUIButton::set_button, VegUINode::set_node

The popup menu widget.
An item in VegUIMenu object
vegUI element type for VegUIMenu
this.add_item = function(content,
script,
lIcon)
Adds an item to the menu
Array , holds the VegUIMenuItem objects in this menu
function VegUIMenu(refName,
Parent,
Manager)
Constructor
this.befriend = function(FMArr,
noSpread)
Befriends several menues, making sure only one of them can be open at the same time
this.build = this.build_menu = function(toNode)
Builds the menu
this.close = function()
Close this menu and all open sub menues
this.close_friends = function()
Closes all friend menues
this.close_children = function()
Closes all child menues
this.flush = function()
Clears the menu of all items
this.get_open = function()
this.get_tail = function()
Best function name EVER
this.init_close = function()
Starts a timer that will close the menu in this.<closeTime> ms.
this.is_active = function()
Checks if this or any of the child menues of this menu is active
this.link_menu = function(itemIdx,
Menu)
Links another VegUIMenu element as a subment to this menu.
this.popup = function(x,
y)
Shows the menu.
this.set = this.set_menu = function(x,
y,
w,
closeTime,
cN,
arrowImg,
nSpace)
Sets the most common template properties of this menu
vegUI element type for VegUIMenuItem
function VegUIMenuItem(refName,
Parent,
Manager)
constructor
this.build = this.build_mnuitem = function(toNode)
Builds the menu item
this.set = this.set_mnuitem = function(content,
script,
lIcon,
rIcon,
h,
lIconW,
rIconW,
nClass,
hClass)
Sets the most common template properties for the menu item
The most basic VegUI Element.
enable event handling for VUI_MOUSE_OUT
enable event handling for VUI_MOUSE_OVER
int, time it takes before the menu is closed after the mouse cursor has left it
string, path of the image to use for the arrow that indicates a nested menu
int, space between this menu and its child menu
bool if true the menu will be allowed to go outside of the manager node’s proportions.
bool, if true there will be no fade effects even if init_fx was called on the manager
int, limit of fade in effect, if set the fade effect will be halted at the selected value (0-100)
int, time of fade effect (ms)
function VegUINode(refName,
Parent,
Manager)
this.build_element = function(VegUIObj,
toNode)
builds a VegUIElement.
this.build = this.build_node = function(toNode,
takeNode)
build a HTML node from the template properties of this element.
When an item is added via the add_item method then it will also be added to the Items property of the menu.
this.set = this.set_node = function(nodeType,
w,
h,
x,
y,
pos,
z)
Template Function
function VegUIButton(refName,
Parent,
Manager)
Constructor
this.build = this.build_button = function(toNode)
Builds the button element
this.set = this.set_button = function(x,
y,
w,
h,
cssNormal,
cssMDown,
c)
sets the most common template properties for the button