> For the complete documentation index, see [llms.txt](https://docs.flatredball.com/gum/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.flatredball.com/gum/gum-tool/plugins/pluginbase.addmenuitem.md).

# AddMenuItem

## Introduction

The AddMenuEntry function adds items to Gum's main menu. It takes the action to run when the item is clicked, followed by the menu path: the first string names the top-level menu (an existing one such as "Content", or a new one, which is inserted before "Help") and each following string is a submenu or, last, the item itself.

AddMenuEntry returns a MenuItemModel. This is a plain object with Header, IsEnabled, IsCheckable, IsChecked, and ToolTip properties; changing them updates the rendered menu item. A plugin that only uses AddMenuEntry does not need to reference any UI framework, and its menu items appear on every operating system (in the macOS menu bar on a Mac).

## Code Example

The following shows how to create a menu called "My Plugin" which contains two items: First and Second. Clicking each item shows a message through the injected dialog service. Add the following to your plugin's **StartUp** function.

```csharp
// Add startup logic here:
AddMenuEntry(() => _dialogService.ShowMessage("You clicked first"), "My Plugin", "First");

var second = AddMenuEntry(() => _dialogService.ShowMessage("You clicked second"), "My Plugin", "Second");

// The returned model can be changed later, for example after a tab is shown or hidden:
second.Header = "Second (visited)";
```

![](https://2695663588-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fzQmxQ1VeUFHcoo2c%2Fuploads%2Fgit-blob-089a28d257904e72304fbbcf0ced34081b8b5f7a%2FBeforeClickingFirstGum.png?alt=media)

## AddMenuItem (obsolete)

Plugins written for the older WPF tool called AddMenuItem, which returned a WPF System.Windows.Controls.MenuItem and required subscribing to its Click event. The current tool does not have AddMenuItem, and it does not load plugins that reference WPF. Replace it with AddMenuEntry: move the Click handler into the action argument, and change any Header or IsEnabled updates to the returned MenuItemModel. See [Migrating a WPF plugin](/gum/gum-tool/plugins.md#migrating-a-wpf-plugin).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.flatredball.com/gum/gum-tool/plugins/pluginbase.addmenuitem.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
