{"id":41083,"date":"2023-11-15T16:01:55","date_gmt":"2023-11-15T21:01:55","guid":{"rendered":"https:\/\/mjtsai.com\/blog\/?p=41083"},"modified":"2023-11-15T16:01:55","modified_gmt":"2023-11-15T21:01:55","slug":"search-suggestion-menus-in-appkit","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2023\/11\/15\/search-suggestion-menus-in-appkit\/","title":{"rendered":"Search Suggestion Menus in AppKit"},"content":{"rendered":"<p><a href=\"https:\/\/micro.virtualsanity.com\/2023\/11\/14\/search-suggestion-menus.html\">John Brayton<\/a>:<\/p>\n<blockquote cite=\"https:\/\/micro.virtualsanity.com\/2023\/11\/14\/search-suggestion-menus.html\">\n<p>Even though Safari, Mail, and Finder implement search suggestion menus, there is no standard AppKit mechanism for providing them in AppKit. Popping up an <code>NSMenu<\/code> does not work because the search field cannot receive keystrokes while the menu is displayed.<\/p>\n<p>Interestingly there <em>is<\/em> a good mechanism for providing search suggestion menus in SwiftUI, but incorporating that mechanism into an AppKit-based application looks much more difficult than just using an <code>NSHostingView<\/code>.<\/p>\n<p>I ended up starting with a <a href=\"https:\/\/github.com\/dougzilla32\/CustomMenus\">CustomMenus<\/a> sample project. This 2018 project by <a href=\"https:\/\/github.com\/dougzilla32\">Doug Stein<\/a> is a Swift port of Apple Objective-C sample code from 2012.<\/p>\n<\/blockquote>","protected":false},"excerpt":{"rendered":"<p>John Brayton: Even though Safari, Mail, and Finder implement search suggestion menus, there is no standard AppKit mechanism for providing them in AppKit. Popping up an NSMenu does not work because the search field cannot receive keystrokes while the menu is displayed. Interestingly there is a good mechanism for providing search suggestion menus in SwiftUI, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"apple_news_api_created_at":"2023-11-15T21:02:02Z","apple_news_api_id":"84646207-9cd3-4b10-bbbc-238bc37fa111","apple_news_api_modified_at":"2023-11-15T21:02:02Z","apple_news_api_revision":"AAAAAAAAAAD\/\/\/\/\/\/\/\/\/\/w==","apple_news_api_share_url":"https:\/\/apple.news\/AhGRiB5zTSxC7vCOLw3-hEQ","apple_news_coverimage":0,"apple_news_coverimage_caption":"","apple_news_is_hidden":false,"apple_news_is_paid":false,"apple_news_is_preview":false,"apple_news_is_sponsored":false,"apple_news_maturity_rating":"","apple_news_metadata":"\"\"","apple_news_pullquote":"","apple_news_pullquote_position":"","apple_news_slug":"","apple_news_sections":"\"\"","apple_news_suppress_video_url":false,"apple_news_use_image_component":false,"footnotes":""},"categories":[4],"tags":[69,30,2385,74,71,1812],"class_list":["post-41083","post","type-post","status-publish","format-standard","hentry","category-programming-category","tag-cocoa","tag-mac","tag-macos-14-sonoma","tag-opensource","tag-programming","tag-swiftui"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/41083","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/comments?post=41083"}],"version-history":[{"count":1,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/41083\/revisions"}],"predecessor-version":[{"id":41084,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/41083\/revisions\/41084"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=41083"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=41083"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=41083"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}