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

# control(_:textShouldBeginEditing:)

Invoked when the user tries to enter a character in a cell of a control that allows editing of text (such as a text field or form field).

## Declaration

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

## Parameters

- `control`: The control whose content is about to be edited.
- `fieldEditor`: The field editor of the control.

## Return Value

Return Value true if the control’s field editor should be allowed to start editing the text; otherwise, false.

## Discussion

Discussion You can use this method to allow or disallow editing in a control. This message is sent by the control directly to its delegate object.

## See Also

### Responding to Text Editing

- [control(_:textShouldEndEditing:)](appkit/nscontroltexteditingdelegate/control(_:textshouldendediting:).md)
