Skip to content

Menu

Extends

Implements

Constructors

new Menu()

new Menu(): Menu

Returns

Menu

Overrides

Component.constructor

Properties

_children

_children: Component[]

Child Components attached to current component, will be unloaded on unloading parent component

Inherited from

Component._children


_events

_events: EventRef[]

Events that are attached to the current component, will be detached on unloading parent component

Inherited from

Component._events


_loaded

_loaded: boolean

Whether the component and its children are loaded

Inherited from

Component._loaded


bgEl

bgEl: HTMLElement

Background for the suggestion menu


currentSubmenu?

optional currentSubmenu: Menu

The currently active submenu, if any


dom

dom: HTMLElement

DOM element of the menu


items

items: MenuItem[]

Items contained in the menu


parentMenu

parentMenu: null | Menu

Parent menu of the current menu


scope

scope: Scope

Scope in which the menu is active


sections

sections: string[]

Sections within the menu


useNativeMenu

useNativeMenu: boolean

Whether the menu is rendered in native mode

Methods

addChild()

addChild<T>(component): T

Adds a child component, loading it if this component is loaded

Type Parameters

T extends Component

Parameters

component: T

Returns

T

Inherited from

Component.addChild


addItem()

addItem(cb): this

Adds a menu item. Only works when menu is not shown yet.

Parameters

cb

Returns

this


addSeparator()

addSeparator(): this

Adds a separator. Only works when menu is not shown yet.

Returns

this


close()

close(): void

Returns

void

Implementation of

CloseableComponent.close

Inherited from

CloseableComponent.close


hide()

hide(): this

Returns

this


hideCallback()

hideCallback(): void

Callback to execute when the menu is hidden

Returns

void


load()

load(): void

Load this component and its children

Returns

void

Inherited from

Component.load


onHide()

onHide(callback): void

Parameters

callback

Returns

void


onload()

onload(): void

Override this to load your component

Returns

void

Inherited from

Component.onload


onunload()

onunload(): void

Override this to unload your component

Returns

void

Inherited from

Component.onunload


register()

register(cb): void

Registers a callback to be called when unloading

Parameters

cb

Returns

void

Inherited from

Component.register


registerDomEvent()

registerDomEvent(el, type, callback, options)

registerDomEvent<K>(el, type, callback, options?): void

Registers an DOM event to be detached when unloading

Type Parameters

K extends keyof WindowEventMap

Parameters

el: Window

type: K

callback

options?: boolean | AddEventListenerOptions

Returns

void

Inherited from

Component.registerDomEvent

registerDomEvent(el, type, callback, options)

registerDomEvent<K>(el, type, callback, options?): void

Registers an DOM event to be detached when unloading

Type Parameters

K extends keyof DocumentEventMap

Parameters

el: Document

type: K

callback

options?: boolean | AddEventListenerOptions

Returns

void

Inherited from

Component.registerDomEvent

registerDomEvent(el, type, callback, options)

registerDomEvent<K>(el, type, callback, options?): void

Registers an DOM event to be detached when unloading

Type Parameters

K extends keyof HTMLElementEventMap

Parameters

el: HTMLElement

type: K

callback

options?: boolean | AddEventListenerOptions

Returns

void

Inherited from

Component.registerDomEvent


registerEvent()

registerEvent(eventRef): void

Registers an event to be detached when unloading

Parameters

eventRef: EventRef

Returns

void

Inherited from

Component.registerEvent


registerInterval()

registerInterval(id): number

Registers an interval (from setInterval) to be cancelled when unloading Use setInterval instead of setInterval to avoid TypeScript confusing between NodeJS vs Browser API

Parameters

id: number

Returns

number

Inherited from

Component.registerInterval


registerScopeEvent()

registerScopeEvent(keymapEventHandler): void

Parameters

keymapEventHandler: KeymapEventHandler

Returns

void

Inherited from

Component.registerScopeEvent


removeChild()

removeChild<T>(component): T

Removes a child component, unloading it

Type Parameters

T extends Component

Parameters

component: T

Returns

T

Inherited from

Component.removeChild


setNoIcon()

setNoIcon(): this

Returns

this


setUseNativeMenu()

setUseNativeMenu(useNativeMenu): this

Force this menu to use native or DOM. (Only works on the desktop app)

Parameters

useNativeMenu: boolean

Returns

this


showAtMouseEvent()

showAtMouseEvent(evt): this

Parameters

evt: MouseEvent

Returns

this


showAtPosition()

showAtPosition(position, doc?): this

Parameters

position: MenuPositionDef

doc?: Document

Returns

this


unload()

unload(): void

Unload this component and its children

Returns

void

Inherited from

Component.unload