NSSearchField with Suggestions view underneath like Spotlight MacOS cocoa Swift 4.2

782 Views Asked by At

I want to write a MacOS Cocoa Desktop App with XCode 10 and Swift 4.2. It should have a searchfield with a suggestions view opening as you keep typing like Google Search or Spotlight with autocompletion. However I'm completely new to Cocoa programming.

I have already tried to add an NSSearchField and a dynamically added NSPopOver object with subclass of NSTableView which contains all the suggestions. But I am not happy with the suggestions view because of the anchor/arrow that appears with it. It seems like it breaks the UI guidelines.

Thus I have tried to implement my own custom subclass of NSView containing the suggestions. It works fine but I struggle with simple things like making it hide/disappear as soon as any other area is clicked in the app.

Does anyone know a good example as best practice for this task or have some sample code?

0

There are 0 best solutions below