Represents a menu flyout for displaying commands.
Syntax
<div data-win-control="WinJS.UI.Menu" />
var object = new WinJS.UI.Menu();
Members
The Menu object has these types of members:
Events
The Menu object has these events.
| Event | Description |
|---|---|
| onafterhide |
Occurs immediately after the Menu is hidden. |
| onaftershow |
Occurs after the Menu is shown. |
| onbeforehide |
Occurs before the Menu is hidden |
| onbeforeshow |
Occurs before a hidden Menu is shown. |
Methods
The Menu object has these methods.
| Method | Description |
|---|---|
| addEventListener |
Registers an event handler for the specified event. |
| getCommandById |
Returns the MenuCommand object identified by id. |
| hide |
Hides the Menu. |
| hideCommands |
Hides the specified commands of the Menu. |
| Menu |
Creates a new Menu object. |
| removeEventListener |
Removes an event handler that the addEventListener method registered. |
| show |
Shows the Menu, if hidden, regardless of other states. |
| showCommands |
Shows the specified commands of the Menu. |
| showOnlyCommands |
Shows the specified commands of the Menu while hiding all other commands. |
Properties
The Menu object has these properties.
| Property | Description |
|---|---|
|
Gets or sets the default alignment to be used for this Menu. | |
|
Gets or sets the default anchor to be used for this Menu. | |
|
Sets the MenuCommand objects that appear in the menu | |
|
Gets the DOM element that hosts the Menu. | |
|
Gets a value that indicates whether the Menu is hidden or in the process of becoming hidden. | |
|
Gets or sets the default placement to be used for this Menu. |
Remarks
You should add the menu flyout as a direct child of the <body> element.
Styling the Menu
To customize a Menu, you can define your own styles for these CSS classes (defined by the Windows Library for JavaScript style sheets):
| CSS class | Description |
|---|---|
|
win-command |
Styles the commands in the Menu. |
|
win-menu |
Styles the entire Menu control. |
Note There are several CSS classes that are shared between multiple Windows Library for JavaScript controls. To limit your custom styles to a specific control, assign the control an ID or custom class name and use that as part of your style selector.
Requirements
|
Namespace |
WinJS.UI |
|---|---|
|
Library |
|
Build date: 12/5/2012