Options
All
  • Public
  • Public/Protected
  • All
Menu

A context menu GUI element.

Hierarchy

Index

Constructors

constructor

  • new ContextMenu(document: Document, x: number, y: number, items: Element[], dismissCallback?: DismissCallback, immediateDisplay?: boolean): ContextMenu
  • Parameters

    • document: Document

      The DOM document for which to make this context menu.

    • x: number

      Position of the menu. The context menu may ignore this position if the menu would appear off-screen.

    • y: number

      Position of the menu.

    • items: Element[]

      The items to show in the menu. These should be list items containing links appropriately formatted for a menu.

    • Optional dismissCallback: DismissCallback

      Function to call when the menu is dismissed.

    • Default value immediateDisplay: boolean = true

      If true, will call render from the constructor.

    Returns ContextMenu

Properties

Protected $menu

$menu: JQuery

The jQuery equivalent of menu.

Protected $toggle

$toggle: JQuery

The jQuery equivalent of toggle.

Protected backdrop

backdrop: Element

Private dismissCallback

dismissCallback: DismissCallback | undefined

Protected dismissed

dismissed: boolean

Protected dropdown

dropdown: HTMLElement

Protected menu

menu: HTMLElement

The Element that contains the list of menu items. This Element is an HTML list. It is created at construction of the object and deleted only when the object is destroyed. This is what the ContextMenu.render method should populate.

Protected toggle

toggle: HTMLElement

The toggle element of the dropdown menu. Even though it is not shown for our menus, it is necessary, and plays a role in how the menu works.

Private x

x: number

Private y

y: number

Methods

Private backdropClickHandler

  • backdropClickHandler(): false

Private contentsClickHandler

  • contentsClickHandler(ev: Event): false
  • Event handler for clicks on the contents. Dismissed the menu.

    Parameters

    • ev: Event

    Returns false

dismiss

  • dismiss(): void

Protected display

  • display(items: Element[]): void

handleToggleFocus

  • handleToggleFocus(): void
  • Event handler for focus events on the toggle. Bootstrap focuses the toggle when the dropdown is shown. This can cause problems on some platforms if the dropdown is meant to have a descendant focused. (IE in particular grants focus asynchronously.) This method can be used to focus the proper element.

    Returns void

Protected render

  • render(items: Element[]): void
  • Subclasses can override this to customize what is shown to the user. For instance, subclasses could accept a list of items which is more complex than DOM Element objects. Or could include in the list shown to the user some additional GUI elements.

    Parameters

    • items: Element[]

      The list of items that should make up the menu.

    Returns void

Generated using TypeDoc