Share via


WinJS.UI.MenuCommand object

A command to be displayed in a Menu object.

Syntax

<button data-win-control="WinJS.UI.MenuCommand" />
var object = new WinJS.UI.MenuCommand();

Members

The MenuCommand object has these types of members:

  • Constructors
  • Methods
  • Properties

Constructors

The MenuCommand object has these constructors.

Constructor Description
MenuCommand

Creates a new MenuCommand object.

 

Methods

The MenuCommand object has these methods.

Method Description
addEventListener

Registers an event handler for the specified event.

dispose

Releases resources held by this MenuCommand. Call this method when the MenuCommand is no longer needed. After calling this method, the MenuCommand becomes unusable.

removeEventListener

Removes an event handler that the addEventListener method registered.

 

Properties

The MenuCommand object has these properties.

Property Access type Description

disabled

Read/write

Gets or sets a value that indicates whether the MenuCommand is disabled.

element

Read-only

Gets the DOM element that hosts the MenuCommand.

extraClass

Read/write

Adds an extra CSS class during construction.

flyout

Read/write

Gets or sets the Flyout object displayed by this command. The specified flyout is shown when the MenuCommand's button is invoked.

hidden

Read-only

Gets a value that indicates whether the MenuCommand is hidden or in the process of becoming hidden.

id

Read-only

Gets the element identifier (ID) of the command.

label

Read/write

Gets or sets the label of the command.

onclick

Read/write

Gets or sets the function to be invoked when the command is clicked.

selected

Read/write

Gets or sets the selected state of a toggle button.

type

Read-only

Gets the type of the command.

 

Remarks

Styling the MenuCommand

CSS classes

To customize a MenuCommand, 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 entire MenuCommand control.

 

Requirements

Minimum WinJS version

WinJS 1.0

Namespace

WinJS.UI

See also

WinJS.UI Namespace

Menu

Flyout

Displaying popups

Laying out your UI

HTML flyout control sample

Designers

Command patterns

Flyout

Guidelines for flyouts

Context menu

Guidelines for context menus