How can I show text input suggestions in AppKit?

Asked on 07/31/2024

1 search

To show text input suggestions in AppKit, you can use the new API introduced in macOS Sequoia. This API allows your app to provide custom suggestions as people type in a system-standard suggestions menu. Here’s how you can get started:

  1. Set the suggestionsDelegate Property: Begin by setting the suggestionsDelegate property on the text field. This delegate is responsible for providing suggestions as text is typed.

  2. Respond with Results: The delegate can respond with results both synchronously and asynchronously. It can also optionally customize the text completions on highlight and selection.

  3. Design Tips:

    • Ensure that the suggestions displayed are relevant to the typed text.
    • Provide consistent and predictable suggestions to preserve muscle memory and build trust.
    • When providing asynchronous suggestions, place those after the immediate suggestions you already provided.
    • Keep the suggestions simple and only provide the most important results to make it easy to find the right result quickly.

For more details, you can refer to the session What’s new in AppKit at the timestamp 17:22.