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:
-
Set the
suggestionsDelegate
Property: Begin by setting thesuggestionsDelegate
property on the text field. This delegate is responsible for providing suggestions as text is typed. -
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.
-
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.

Support semantic search with Core Spotlight
Learn how to provide semantic search results in your app using Core Spotlight. Understand how to make your app’s content available in the user’s private, on-device index so people can search for items using natural language. We’ll also share how to optimize your app’s performance by scheduling indexing activities. To get the most out of this session, we recommend first checking out Core Spotlight documentation on the Apple Developer website.

What’s new in AppKit
Discover the latest advances in Mac app development. Get an overview of the new features in macOS Sequoia, and how to adopt them in your app. Explore new ways to integrate your existing code with SwiftUI. Learn about the improvements made to numerous AppKit controls, like toolbars, menus, text input, and more.

What’s new in SwiftUI
Learn how you can use SwiftUI to build great apps for any Apple platform. Explore a fresh new look and feel for tabs and documents on iPadOS. Improve your window management with new windowing APIs, and gain more control over immersive spaces and volumes in your visionOS apps. We’ll also take you through other exciting refinements that help you make expressive charts, customize and layout text, and so much more.