---
title: "textView(_:editMenuForTextIn:suggestedActions:)"
framework: uikit
role: symbol
role_heading: Instance Method
path: "uikit/uitextviewdelegate/textview(_:editmenufortextin:suggestedactions:)"
---

# textView(_:editMenuForTextIn:suggestedActions:)

Asks the delegate for the menu to display in the text view, based on the text range and actions the system provides.

## Declaration

```swift
optional func textView(_ textView: UITextView, editMenuForTextIn range: NSRange, suggestedActions: [UIMenuElement]) -> UIMenu?
```

## Parameters

- `textView`: The text view requesting the menu.
- `range`: The character range the menu is presenting for.
- `suggestedActions`: The actions and commands the system suggests.

## Return Value

Return Value Returns a menu describing the desired menu hierarchy. Return nil to present the default system menu.

## Discussion

Discussion The following example returns a menu that includes an “Add Bookmark” action and also a “Highlight” action, but only if the selected text range is greater than zero. func textView(_ textView: UITextView, editMenuForTextIn range: NSRange, suggestedActions: [UIMenuElement]) -> UIMenu? {     var additionalActions: [UIMenuElement] = []     if range.length > 0 {         let highlightAction = UIAction(title: "Highlight", image: UIImage(systemName: "highlighter")) { action in             // The highlight action.         }         additionalActions.append(highlightAction)     }     let addBookmarkAction = UIAction(title: "Add Bookmark", image: UIImage(systemName: "bookmark")) { action in         // The bookmark action.     }     additionalActions.append(addBookmarkAction)     return UIMenu(children: suggestedActions + additionalActions) }
