{"id":24846,"date":"2019-04-02T15:22:00","date_gmt":"2019-04-02T19:22:00","guid":{"rendered":"https:\/\/mjtsai.com\/blog\/?p=24846"},"modified":"2019-04-02T15:22:00","modified_gmt":"2019-04-02T19:22:00","slug":"using-drag-and-drop-with-nstableview","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2019\/04\/02\/using-drag-and-drop-with-nstableview\/","title":{"rendered":"Using Drag and Drop with NSTableView"},"content":{"rendered":"<p><a href=\"https:\/\/www.natethompson.io\/2019\/03\/23\/nstableview-drag-and-drop.html\">Nate Thompson<\/a> (via <a href=\"https:\/\/twitter.com\/danielpunkass\/status\/1109944282453106693\">Daniel Jalkut<\/a>):<\/p>\n<blockquote cite=\"https:\/\/www.natethompson.io\/2019\/03\/23\/nstableview-drag-and-drop.html\"><p>I recently tried to implement drag and drop with <code>NSTableView<\/code> in a project and ran into a bunch of issues with finding resources that actually helped. Such is the life of a Cocoa developer. So here&rsquo;s my attempt at the <em>definitive guide<\/em> to drag and drop with <code>NSTableView<\/code>. (This should also apply to <code>NSOutlineView<\/code>, since they work in a similar way.)<\/p><p>[&#8230;]<\/p><p>There&rsquo;s a bug in <code>NSTableView<\/code> that requires implementing <code>tableView(_:heightOfRow:)<\/code> to get the <code>gap<\/code> style to animate correctly.<\/p><p>[&#8230;]<\/p><p>Passing <code>-1<\/code> and <code>on<\/code> will highlight the entire table view.<\/p><\/blockquote>\n<p>Unfortunately, I have not found that highlighting to be reliable since macOS 10.14.<\/p>","protected":false},"excerpt":{"rendered":"<p>Nate Thompson (via Daniel Jalkut): I recently tried to implement drag and drop with NSTableView in a project and ran into a bunch of issues with finding resources that actually helped. Such is the life of a Cocoa developer. So here&rsquo;s my attempt at the definitive guide to drag and drop with NSTableView. (This should [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"apple_news_api_created_at":"2019-04-02T19:22:05Z","apple_news_api_id":"e7ba4fc6-d187-404a-9f10-ad927c79b1ef","apple_news_api_modified_at":"2019-04-02T19:22:06Z","apple_news_api_revision":"AAAAAAAAAAD\/\/\/\/\/\/\/\/\/\/w==","apple_news_api_share_url":"https:\/\/apple.news\/A57pPxtGHQEqfEK2SfHmx7w","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":[131,69,30,1609,71,901],"class_list":["post-24846","post","type-post","status-publish","format-standard","hentry","category-programming-category","tag-bug","tag-cocoa","tag-mac","tag-macos-10-14","tag-programming","tag-swift-programming-language"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/24846","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=24846"}],"version-history":[{"count":1,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/24846\/revisions"}],"predecessor-version":[{"id":24847,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/24846\/revisions\/24847"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=24846"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=24846"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=24846"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}