Interface Menu

The Menu module enables developers to add items to IINA's Plugin menu. An item can be a simple menu item, or a submenu item with subitems.

Example

// create a menu to choose subtitle tracks
const subTracksMenu = menu.item("Subtitle Track");

// add a submenu item for each track
for (const track of core.subtitle.tracks) {
subTracksMenu.addSubmenuItem(
menu.item(
track.title,
// when clicked, set the subtitle track
() => { core.subtitle.id = track.id },
// show checkmark if the track is currently selected
{ selected: track.id === core.subtitle.id }
)
);
}
// add the menu to IINA's Plugin menu
menu.addItem(subTracksMenu);

Available In Entry

Main and Global. However, the two entry points have separate sets of menu items. Menu items created in the Global entry point are available all the time, while menu items created in the Main entry point are only available when the associated window is focused. Global menu items are displayed above the Main menu items. The order of the plugin menu items is illustrated below:

------------------------------
Plugin 1 - Global menu item 1
Plugin 1 - Global menu item 2
Plugin 1 - Main menu item 1 ─┬──► Available when the window is focused
Plugin 1 - Main menu item 2 ─┘
------------------------------
Plugin 2 - Global menu item 1
...

Hierarchy

  • Menu

Methods

  • Creates a new menu item.

    Remarks

    This method does not add the item to the menu. Please use addItem after creating the item.

    Parameters

    • title: string

      The title of the menu item.

    • Optional action: (() => void)

      The callback function to be called when the item is clicked. Pass null when no action is needed.

        • (): void
        • Returns void

    • Optional options: Partial<{
          enabled: boolean;
          selected: boolean;
          keyBinding: string;
      }>

      Additional options for the menu item.

      • enabled: Whether the item is enabled. Defaults to true.
      • selected: Whether the item is selected (has checkmark). Defaults to false.
      • keyBinding: The key binding for the item, in mpv's key binding format.

    Returns MenuItem

  • Adds a menu item to IINA's Plugin menu.

    Parameters

    Returns void

  • Remove a menu item from IINA's Plugin menu.

    Parameters

    • index: number

      The index of the menu item to remove, starting from 0.

    Returns void

  • Remove all menu items for this plugin.

    Returns void

  • Refresh the Plugin menu.

    Returns void

Generated using TypeDoc