<!--
{
  "availability" : [
    "macOS: 10.10.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSControl/edit(withFrame:editor:delegate:event:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSControl(im)editWithFrame:editor:delegate:event:"
  },
  "title" : "edit(withFrame:editor:delegate:event:)"
}
-->

# edit(withFrame:editor:delegate:event:)

Begins editing of the receiver’s text using the specified field editor.

```
func edit(withFrame rect: NSRect, editor textObj: NSText, delegate: Any?, event: NSEvent)
```

## Parameters

`rect`

The bounding rectangle of the control’s cell.

`textObj`

The field editor to use.

`delegate`

The object to use as a delegate for the field editor. This delegate object receives various [`NSText`](/documentation/AppKit/NSText) delegation and notification methods during the course of editing the cell’s contents.

`event`

The [`NSLeftMouseDown`](/documentation/AppKit/NSLeftMouseDown) event that initiated the editing behavior.

## Discussion

For a receiver that is a control with editable text (such as an [`NSTextField`](/documentation/AppKit/NSTextField) object), the field editor is sized to `aRect` and is then activated and editing begins. It’s the responsibility of the delegate to end editing when responding to [`control(_:textShouldEndEditing:)`](/documentation/AppKit/NSControlTextEditingDelegate/control(_:textShouldEndEditing:)). Upon ending the editing session, the delegate should remove any data from the field editor.

---

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)