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

# textShouldBeginEditing(_:)

Invoked when a text object begins to change its text, this method requests permission for `aTextObject` to begin editing.

```
@MainActor optional func textShouldBeginEditing(_ textObject: NSText) -> Bool
```

## Discussion

If the delegate returns <doc://com.apple.documentation/documentation/Swift/true>, the text object proceeds to make changes. If the delegate returns <doc://com.apple.documentation/documentation/Swift/false>, the text object abandons the editing operation. This method is also invoked when the user drags and drops a file onto the text object.

## See Also

[`func becomeFirstResponder() -> Bool`](/documentation/AppKit/NSResponder/becomeFirstResponder())

Notifies the receiver that it’s about to become first responder in its [`NSWindow`](/documentation/AppKit/NSWindow).

[`func makeFirstResponder(NSResponder?) -> Bool`](/documentation/AppKit/NSWindow/makeFirstResponder(_:))

Attempts to make a given responder the first responder for the window.



---

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)