BiMenu

This class represents a menu. Menus can be filled with menu items by adding BiMenuItem objects.

The content model for the menu is very similiar to the content model for BiComponent but there are slight differences.

This class extends BiEventTarget and therefore all methods and fields available for BiEventTarget are also available for BiMenu .

Constructor

new BiMenu ( )

Parameters

No parameters.

Properties

Name Type get set Descripton
children BiMenuItem[] checked The menu items added to the menu
component BiComponent checked If the menu was opened as a context menu for a component then this will point to the component that caused the menu to be shown.

This will return null if the menu is hidden or not opened by a component. In other words by setting visible manually. This is available during the beforeshow event even though the menu is not yet visible. It is also available when the hide event fires.
firstChild BiMenuItem checked Returns the first menu item child
height Number checked checked The heightof the menu
hideTimeStamp Date checked The time when the menu was hidden. This can be useful to find out whether the popup was just hidden.
insetBottom Number checked Border bottom width.
insetLeft Number checked Border left width.
insetRight Number checked Border right width.
insetTop Number checked Border top width.
isVisible Boolean checked Whether the menu is shown on the screen
lastChild BiMenuItem checked Returns the last menu item child
left Number checked checked Sets or gets the left position of the menu relative to the screen
parent BiMenuItem checked The parent menu item in case the menu acts as a sub menu
parentMenu BiMenu checked The parent menu in case the menu acts as a sub menu. This is the same as the parent of the parent menu item
preferredHeight Number checked The preferred height of the menu
preferredWidth Number checked The preferred width of the menu
rightToLeft Boolean checked checked Describes whether the component should be be layed out to support locales using right-to-left fonts. If this is set to null then the rightToLeft property for the parent component is used.
screenLeft Number checked The left postion of the menu relative to the screen
screenTop Number checked The top postion of the menu relative to the screen
showTimeStamp Date checked The time when the menu was shown.
top Number checked checked Sets or gets the top position of the menu relative to the screen
topLevelComponent BiComponent checked Returns the top level ancestor component. This is usually the application window hosting the application.
width Number checked checked The width of the menu
visible Boolean checked Shows or hides the menu

Methods

Name Description
add Adds a menu item to the current menu. The added menu item becomes a child of the current menu. If the menu item is a child of another menu it is first removed from that menu. The second, optional, argument can be used to insert the new menu item before an existing child. If you know the index where you want to insert the item at you might want to consider using addAt instead.
addAt Adds a menu item at the given index to the current menu. The added menu item becomes a child of the current menu. If the menu item is achild of another menu it is first removed from that menu.
contains Returns true if the menu contains another menu item or menu. This means that the current component is an ancestor of the descendant. Note that the current component contains itself so calling component.contains(component) will return true.
hasChildren Returns true if the menu has any child menu items
initAccessibility This is used in accessibility mode to initialize accessibility for the menu. This is called from the constructor and should be overridden by all accessible components to add event handlers. See accessibility documentation for more information.
remove Removes an existing menu item from the component.
removeAll Removes and disposes all menu items in the menu
removeAt Removes the menu item at the given index from the menu.
setLocation Sets the left and top position relative to the screen for the menu.
setSize Sets the width and height of the menu.

Events

Name Type Bubbles Descripton
beforeshow BiEvent Fires before the menu is shown. This is a good place to change the content of the menu to reflect the component causing the menu to be shown
hide BiEvent Fires when the menu is hidden
show BiEvent Fires when the menu is shown

Static Methods

None.

Static Fields

None.

Remarks

The location of the menu is relative to the screen. A menu can only be used as a sub menu for one menu item.

Method Details

add

Adds a menu item to the current menu. The added menu item becomes a child of the current menu. If the menu item is a child of another menu it is first removed from that menu. The second, optional, argument can be used to insert the new menu item before an existing child. If you know the index where you want to insert the item at you might want to consider using addAt instead.

Syntax

object.add
 (
 oChild
 [
 ,oBefore
 ]
 
 )
 

Parameters

Name Type Optional Default Descripton
oChild BiMenuItem The menu item to add
oBefore BiMenuItem checked The existing child do add the new menu item before

Return Type

void

addAt

Adds a menu item at the given index to the current menu. The added menu item becomes a child of the current menu. If the menu item is achild of another menu it is first removed from that menu.

Syntax

object.addAt
 (
 oChild,nIndex
 )
 

Parameters

Name Type Optional Default Descripton
oChild BiMenuItem The menu item to add
nIndex Number The index to add the item at

Return Type

void

contains

Returns true if the menu contains another menu item or menu. This means that the current component is an ancestor of the descendant. Note that the current component contains itself so calling component.contains(component) will return true.

Syntax

object.contains
 (
 oDescendant
 )
 

Parameters

Name Type Optional Default Descripton
oDescendant Object The BiMenu or BiMenuItem to test whether the current component contains it.

Return Type

Boolean

hasChildren

Returns true if the menu has any child menu items

Syntax

object.hasChildren
 (
 
 )
 

Parameters

No arguments.

Return Type

Boolean

initAccessibility

This is used in accessibility mode to initialize accessibility for the menu. This is called from the constructor and should be overridden by all accessible components to add event handlers. See accessibility documentation for more information.

Syntax

object.initAccessibility
 (
 
 )
 

Parameters

No arguments.

Return Type

void

remove

Removes an existing menu item from the component.

Syntax

object.remove
 (
 oChild
 )
 

Parameters

Name Type Optional Default Descripton
oChild BiMenuItem The menu item to remove

Return Type

BiMenuItem

removeAll

Removes and disposes all menu items in the menu

Syntax

object.removeAll
 (
 
 )
 

Parameters

No arguments.

Return Type

void

removeAt

Removes the menu item at the given index from the menu.

Syntax

object.removeAt
 (
 nIndex
 )
 

Parameters

Name Type Optional Default Descripton
nIndex Number The index of the menu item to remove

Return Type

BiMenuItem

setLocation

Sets the left and top position relative to the screen for the menu.

Syntax

object.setLocation
 (
 nLeft,nTop
 )
 

Parameters

Name Type Optional Default Descripton
nLeft Number The new left location for the menu
nTop Number The new top location for the menu

Return Type

void

setSize

Sets the width and height of the menu.

Syntax

object.setSize
 (
 nWidth,nHeight
 )
 

Parameters

Name Type Optional Default Descripton
nWidth Number The new width for the menu
nHeight Number The new height for the menu

Return Type

void