Class Menu

Represents a menu flyout for displaying commands.

Index

Constructor methods

Properties

Methods

Constructor methods

constructor(element?: HTMLElement, options?: any): Menu

Creates a new Menu object.

constructor

Parameters

  • element?: HTMLElement optional

    The DOM element that will host the control.

  • options?: any optional

    The set of properties and values to apply to the new Menu.

Returns

Menu

Properties

public alignment: string

Gets or sets the default alignment to be used for this Menu.

public anchor: HTMLElement

Gets or sets the default anchor to be used for this Menu.

public commands: MenuCommand[]

Sets the MenuCommand objects that appear in the menu.

public element: HTMLElement

Gets the DOM element that hosts the Menu.

public hidden: boolean

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

public placement: string

Gets or sets the default placement to be used for this Menu.

Methods

public addEventListener(type: string, listener: Function, useCapture?: boolean)

Registers an event handler for the specified event.

Parameters

  • type: string

    The event type to register. It must be beforeshow, beforehide, aftershow, or afterhide.

  • listener: Function

    The event handler function to associate with the event.

  • useCapture?: boolean optional

    Set to true to register the event handler for the capturing phase; otherwise, set to false to register the event handler for the bubbling phase.

public dispose()

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

public getCommandById(id: string): MenuCommand

Returns the MenuCommand object identified by id.

Parameters

  • id: string

    The element identifier (ID) of the command to be returned.

Returns

MenuCommand

The command identified by id.

public hide()

Hides the Menu.

public hideCommands(commands: Array<any>, immediate: boolean)

Hides the specified commands of the Menu.

Parameters

  • commands: Array<any>

    The commands to hide. The array elements may be MenuCommand objects, or the string identifiers (IDs) of commands.

  • immediate: boolean

    The parameter immediate is not supported and may be altered or unavailable in the future. true to hide the commands immediately, without animating them; otherwise, false.

public onafterhide(eventInfo: Event)

Occurs immediately after the Menu is hidden.

Parameters

  • eventInfo: Event

    An object that contains information about the event.

public onaftershow(eventInfo: Event)

Occurs after the Menu is shown.

Parameters

  • eventInfo: Event

    An object that contains information about the event.

public onbeforehide(eventInfo: Event)

Occurs before the Menu is hidden.

Parameters

  • eventInfo: Event

    An object that contains information about the event.

public onbeforeshow(eventInfo: Event)

Occurs before a hidden Menu is shown.

Parameters

  • eventInfo: Event

    An object that contains information about the event.

public removeEventListener(type: string, listener: Function, useCapture?: boolean)

Removes an event handler that the addEventListener method registered.

Parameters

  • type: string

    The event type to unregister. It must be beforeshow, beforehide, aftershow, or afterhide.

  • listener: Function

    The event handler function to remove.

  • useCapture?: boolean optional

    Set to true to remove the capturing phase event handler; set to false to remove the bubbling phase event handler.

public show(anchor: HTMLElement, placement: string, alignment: string)

Shows the Menu, if hidden, regardless of other states.

Parameters

  • anchor: HTMLElement

    Required. The DOM element to anchor the Menu.

  • placement: string

    The placement of the Menu to the anchor: top, bottom, left, or right.

  • alignment: string

    For top or bottom placement, the alignment of the Menu to the anchor's edge: center, left, or right.

public showCommands(commands: Array<any>, immediate: boolean)

Shows the specified commands of the Menu.

Parameters

  • commands: Array<any>

    The commands to show. The array elements may be Menu objects, or the string identifiers (IDs) of commands.

  • immediate: boolean

    The parameter immediate is not supported and may be altered or unavailable in the future. true to show the commands immediately, without animating them; otherwise, false.

public showOnlyCommands(commands: Array<any>, immediate: boolean)

Shows the specified commands of the Menu while hiding all other commands.

Parameters

  • commands: Array<any>

    The commands to show. The array elements may be MenuCommand objects, or the string identifiers (IDs) of commands.

  • immediate: boolean

    The parameter immediate is not supported and may be altered or unavailable in the future. true to show the specified commands (and hide the others) immediately, without animating them; otherwise, false.