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

# selectText(_:)

Selects text in the currently selected cell or in the key cell.

```
func selectText(_ sender: Any?)
```

## Discussion

If the currently selected cell is editable and enabled, its text is selected. Otherwise, the key cell is selected.

## See Also

[`selectText(_:)`](/documentation/AppKit/NSTextField/selectText(_:))

Ends editing in the text field and, if it’s selectable, selects the entire text content.

[`keyCell`](/documentation/AppKit/NSMatrix/keyCell)

The cell that will be clicked when the user presses the Space bar.



---

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)