Skip to content

Menu

Defined in: obsidian.d.ts:2608

Extends

Implements

Constructors

new Menu()

new Menu(): Menu

Defined in: obsidian.d.ts:2613

Returns

Menu

Overrides

Component.constructor

Properties

_children

_children: Component[]

Defined in: src/obsidian/augmentations/Components/Component.d.ts:9

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

Inherited from

Component._children


_events

_events: EventRef[]

Defined in: src/obsidian/augmentations/Components/Component.d.ts:13

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

Inherited from

Component._events


_loaded

_loaded: boolean

Defined in: src/obsidian/augmentations/Components/Component.d.ts:17

Whether the component and its children are loaded

Inherited from

Component._loaded


bgEl

bgEl: HTMLElement

Defined in: src/obsidian/augmentations/Menu.d.ts:10

Background for the suggestion menu


currentSubmenu?

optional currentSubmenu: Menu

Defined in: src/obsidian/augmentations/Menu.d.ts:14

The currently active submenu, if any


dom

dom: HTMLElement

Defined in: src/obsidian/augmentations/Menu.d.ts:18

DOM element of the menu


items

items: MenuItem[]

Defined in: src/obsidian/augmentations/Menu.d.ts:22

Items contained in the menu


parentMenu

parentMenu: null | Menu

Defined in: src/obsidian/augmentations/Menu.d.ts:26

Parent menu of the current menu


scope

scope: Scope

Defined in: src/obsidian/augmentations/Menu.d.ts:30

Scope in which the menu is active


sections

sections: string[]

Defined in: src/obsidian/augmentations/Menu.d.ts:34

Sections within the menu


useNativeMenu

useNativeMenu: boolean

Defined in: src/obsidian/augmentations/Menu.d.ts:44

Whether the menu is rendered in native mode

Methods

addChild()

addChild<T>(component): T

Defined in: obsidian.d.ts:887

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

Defined in: obsidian.d.ts:2629

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

Parameters

cb

(item) => any

Returns

this


addSeparator()

addSeparator(): this

Defined in: obsidian.d.ts:2634

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

Returns

this


close()

close(): void

Defined in: obsidian.d.ts:2649

Returns

void

Implementation of

CloseableComponent.close

Inherited from

CloseableComponent.close


hide()

hide(): this

Defined in: obsidian.d.ts:2647

Returns

this


hideCallback()

hideCallback(): void

Defined in: src/obsidian/augmentations/Menu.d.ts:53

Callback to execute when the menu is hidden

Returns

void


load()

load(): void

Defined in: obsidian.d.ts:865

Load this component and its children

Returns

void

Inherited from

Component.load


onHide()

onHide(callback): void

Defined in: obsidian.d.ts:2653

Parameters

callback

() => any

Returns

void


onload()

onload(): void

Defined in: obsidian.d.ts:871

Override this to load your component

Returns

void

Inherited from

Component.onload


onunload()

onunload(): void

Defined in: obsidian.d.ts:882

Override this to unload your component

Returns

void

Inherited from

Component.onunload


register()

register(cb): void

Defined in: obsidian.d.ts:897

Registers a callback to be called when unloading

Parameters

cb

() => any

Returns

void

Inherited from

Component.register


registerDomEvent()

Call Signature

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

Defined in: obsidian.d.ts:907

Registers an DOM event to be detached when unloading

Type Parameters

K extends keyof WindowEventMap

Parameters
el

Window

type

K

callback

(this, ev) => any

options?

boolean | AddEventListenerOptions

Returns

void

Inherited from

Component.registerDomEvent

Call Signature

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

Defined in: obsidian.d.ts:912

Registers an DOM event to be detached when unloading

Type Parameters

K extends keyof DocumentEventMap

Parameters
el

Document

type

K

callback

(this, ev) => any

options?

boolean | AddEventListenerOptions

Returns

void

Inherited from

Component.registerDomEvent

Call Signature

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

Defined in: obsidian.d.ts:917

Registers an DOM event to be detached when unloading

Type Parameters

K extends keyof HTMLElementEventMap

Parameters
el

HTMLElement

type

K

callback

(this, ev) => any

options?

boolean | AddEventListenerOptions

Returns

void

Inherited from

Component.registerDomEvent


registerEvent()

registerEvent(eventRef): void

Defined in: obsidian.d.ts:902

Registers an event to be detached when unloading

Parameters

eventRef

EventRef

Returns

void

Inherited from

Component.registerEvent


registerInterval()

registerInterval(id): number

Defined in: obsidian.d.ts:924

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

Defined in: src/obsidian/augmentations/Components/Component.d.ts:19

Parameters

keymapEventHandler

KeymapEventHandler

Returns

void

Inherited from

Component.registerScopeEvent


removeChild()

removeChild<T>(component): T

Defined in: obsidian.d.ts:892

Removes a child component, unloading it

Type Parameters

T extends Component

Parameters

component

T

Returns

T

Inherited from

Component.removeChild


setNoIcon()

setNoIcon(): this

Defined in: obsidian.d.ts:2618

Returns

this


setUseNativeMenu()

setUseNativeMenu(useNativeMenu): this

Defined in: obsidian.d.ts:2624

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

Parameters

useNativeMenu

boolean

Returns

this


showAtMouseEvent()

showAtMouseEvent(evt): this

Defined in: obsidian.d.ts:2639

Parameters

evt

MouseEvent

Returns

this


showAtPosition()

showAtPosition(position, doc?): this

Defined in: obsidian.d.ts:2643

Parameters

position

MenuPositionDef

doc?

Document

Returns

this


unload()

unload(): void

Defined in: obsidian.d.ts:876

Unload this component and its children

Returns

void

Inherited from

Component.unload