{"id":20,"date":"2005-08-02T02:01:40","date_gmt":"2005-08-02T06:01:40","guid":{"rendered":""},"modified":"2018-10-31T10:16:18","modified_gmt":"2018-10-31T17:16:18","slug":"cmd-click-the-subtle-secret-of-mac-os-x","status":"publish","type":"post","link":"https:\/\/www.corbinstreehouse.com\/blog\/2005\/08\/cmd-click-the-subtle-secret-of-mac-os-x\/","title":{"rendered":"Cmd &#8211; click. The subtle secret of Mac OS X."},"content":{"rendered":"<p id=\"top\" \/>\n<p>It seems that a lot of people don&#8217;t know how cmd click works in a lot of Mac OS X Cocoa applications. To put it simply, Cmd-clicking on a non key window (or application for that matter) will act like a normal click without making the window key! This is really cool for testing UI things while debugging or testing for memory leaks.<\/p>\n<p>Here is how I use this technique while debugging:<br \/>\n1. I&#8217;m debugging my application with Xcode. Inside of Xcode I have a \u00e2\u20ac\u0153hot\u00e2\u20ac\u009d breakpoint that I don&#8217;t want to enable, since enabling it will make Xcode key, and the key\/focus switching will hit the breakpoint at the wrong time.<br \/>\n2. Because of this, I keep my application key, and Cmd-click on the title bar in Xcode to move the window to where I can see the breakpoint.<br \/>\n3. Then, I Cmd-click the breakpoint, enabling it without setting the window key and never leaving focus from my application that i want to debug.<br \/>\n4. Now, I perform the operation that invokes the breakpoint and debug away.<\/p>\n<p>Sure, you could do this by figuring out how many times the breakpoint was hit, and in gdb ignore the breakpoint for X times, but sometimes that is a pain to do.<\/p>\n<p>I also use this technique while trying to find memory leaks with Object Alloc. Frequently, focus switching causes numerous allocations, and by Cmd-clicking the \u00e2\u20ac\u0153Mark\u00e2\u20ac\u009d button in Object Alloc I can prevent those allocations from happening.<\/p>\n<p>Note that cmd click doesn&#8217;t work 100% correctly with certain components. For instance, NSTableView won&#8217;t change the selected item unless it is key (note that that bug will be fixed).<\/p>\n<p>&#8211;corbin<\/p>\n","protected":false},"excerpt":{"rendered":"<p>It seems that a lot of people don&#8217;t know how cmd click works in a lot of Mac OS X Cocoa applications. To put it simply, Cmd-clicking on a non key window (or application for&#8230; <a class=\"read-more\" href=\"https:\/\/www.corbinstreehouse.com\/blog\/2005\/08\/cmd-click-the-subtle-secret-of-mac-os-x\/\">[read more]<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[6,1],"tags":[63,130,72],"class_list":["post-20","post","type-post","status-publish","format-standard","hentry","category-cocoa","category-general","tag-cocoa","tag-objc","tag-programming"],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p8zn47-k","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.corbinstreehouse.com\/blog\/wp-json\/wp\/v2\/posts\/20","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.corbinstreehouse.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.corbinstreehouse.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.corbinstreehouse.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.corbinstreehouse.com\/blog\/wp-json\/wp\/v2\/comments?post=20"}],"version-history":[{"count":1,"href":"https:\/\/www.corbinstreehouse.com\/blog\/wp-json\/wp\/v2\/posts\/20\/revisions"}],"predecessor-version":[{"id":5336,"href":"https:\/\/www.corbinstreehouse.com\/blog\/wp-json\/wp\/v2\/posts\/20\/revisions\/5336"}],"wp:attachment":[{"href":"https:\/\/www.corbinstreehouse.com\/blog\/wp-json\/wp\/v2\/media?parent=20"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.corbinstreehouse.com\/blog\/wp-json\/wp\/v2\/categories?post=20"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.corbinstreehouse.com\/blog\/wp-json\/wp\/v2\/tags?post=20"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}