Skip to content

Commit

Permalink
update context menu docs to new content structure
Browse files Browse the repository at this point in the history
  • Loading branch information
kkoreilly committed Dec 24, 2024
1 parent a24e597 commit e0d88d6
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 24 deletions.
24 changes: 0 additions & 24 deletions docs/content/2-widgets/2-containers/context-menus.md

This file was deleted.

30 changes: 30 additions & 0 deletions docs/content/context-menu.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
+++
Categories = ["Widgets"]
+++

A **context menu** allows users to take actions relevant to a [[widget]]. Users can open context menus by [[events#context menu|right clicking]] on a widget or [[events#long press]]ing down on a widget for 500 milliseconds, so context menus work on all platforms.

You can add [[button]]s to the context menu of a widget:

```Go
tf := core.NewTextField(b)
tf.AddContextMenu(func(m *core.Scene) {
core.NewButton(m).SetText("Build")
core.NewButton(m).SetText("Run")
})
```

You can remove all of the context menu buttons of a widget:

```Go
tf := core.NewTextField(b)
tf.ContextMenus = nil
```

## Scene context menu

Note that there is still a context menu in the example above since all widgets inherit the [[scene]] context menu items, which consist of various important actions by default, such as the [[settings]] and [[inspector]]. You can remove these items if you want:

```go
myWidget.Scene.ContextMenus = nil
```

0 comments on commit e0d88d6

Please sign in to comment.