---
title: "control(_:textShouldEndEditing:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nscontroltexteditingdelegate/control(_:textshouldendediting:)"
---

# control(_:textShouldEndEditing:)

Invoked when the insertion point tries to leave a cell of the control that has been edited.

## Declaration

```swift
@MainActor optional func control(_ control: NSControl, textShouldEndEditing fieldEditor: NSText) -> Bool
```

## Parameters

- `control`: The control for which editing is about to end.
- `fieldEditor`: The field editor of the control. You can use this parameter to get the edited text.

## Return Value

Return Value true if the insertion point should be allowed to end the editing session; otherwise, false.

## Discussion

Discussion This message is sent only by controls that allow editing of text (such as a text field or a form field). This message is sent by the control directly to its delegate object.

## See Also

### Responding to Text Editing

- [control(_:textShouldBeginEditing:)](appkit/nscontroltexteditingdelegate/control(_:textshouldbeginediting:).md)
