<!--
{
  "availability" : [
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSControlTextEditingDelegate/control(_:textShouldEndEditing:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(pl)NSControlTextEditingDelegate(im)control:textShouldEndEditing:"
  },
  "title" : "control(_:textShouldEndEditing:)"
}
-->

# control(_:textShouldEndEditing:)

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

```
@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

<doc://com.apple.documentation/documentation/Swift/true> if the insertion point should be allowed to end the editing session; otherwise, <doc://com.apple.documentation/documentation/Swift/false>.

## 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.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)