Menu

open external class Menu : MenuItemBase(source)

A type that is either a menu bar on the window on Windows and Linux or as a global menu in the menubar on macOS.

Platform-specific:

  • macOS: if using {@linkcode Menu} for the global menubar, it can only contain {@linkcode Submenu}s.

Constructors

Link copied to clipboard
constructor(rid: Double, id: String)

Types

Link copied to clipboard
external object Companion

Properties

Link copied to clipboard
external val id: String

The id of this item.

Link copied to clipboard
external val kind: String
Link copied to clipboard
external val rid: Double

Functions

Link copied to clipboard
external fun <T : Any> append(items: T): Promise<Void>
external fun <T : Any> append(items: ReadonlyArray<T>): Promise<Void>

Add a menu item to the end of this menu.

Link copied to clipboard
external fun close(): Promise<Void>

Destroys and cleans up this resource from memory. You should not call any method on this object anymore and should drop any reference to it.

Link copied to clipboard
external fun get(id: String): Promise<Any?>

Retrieves the menu item matching the given identifier.

Link copied to clipboard
external fun <T : Any> insert(items: T, position: Double): Promise<Void>
external fun <T : Any> insert(items: ReadonlyArray<T>, position: Double): Promise<Void>

Add a menu item to the specified position in this menu.

Link copied to clipboard
external fun items(): Promise<ReadonlyArray<Any>>

Returns a list of menu items that has been added to this menu.

Link copied to clipboard
external fun popup(): Promise<Void>
external fun popup(at: LogicalPosition = definedExternally, window: Window = definedExternally): Promise<Void>
external fun popup(at: PhysicalPosition = definedExternally, window: Window = definedExternally): Promise<Void>
external fun popup(at: Position = definedExternally, window: Window = definedExternally): Promise<Void>

Popup this menu as a context menu on the specified window.

Link copied to clipboard
external fun <T : Any> prepend(items: T): Promise<Void>
external fun <T : Any> prepend(items: ReadonlyArray<T>): Promise<Void>

Add a menu item to the beginning of this menu.

Link copied to clipboard
external fun remove(item: CheckMenuItem): Promise<Void>
external fun remove(item: IconMenuItem): Promise<Void>
external fun remove(item: MenuItem): Promise<Void>
external fun remove(item: PredefinedMenuItem): Promise<Void>
external fun remove(item: Submenu): Promise<Void>

Remove a menu item from this menu.

Link copied to clipboard
external fun removeAt(position: Double): Promise<Any?>

Remove a menu item from this menu at the specified position.

Link copied to clipboard
external fun setAsAppMenu(): Promise<Menu?>

Sets the app-wide menu and returns the previous one.

Link copied to clipboard
external fun setAsWindowMenu(window: Window = definedExternally): Promise<Menu?>

Sets the window menu and returns the previous one.