{"id":65,"date":"2005-12-06T10:42:45","date_gmt":"2005-12-06T17:42:45","guid":{"rendered":"http:\/\/www.red-sweater.com\/blog\/?p=65"},"modified":"2005-12-06T10:59:30","modified_gmt":"2005-12-06T17:59:30","slug":"center-windows-in-interface-builder","status":"publish","type":"post","link":"https:\/\/redsweater.com\/blog\/65\/center-windows-in-interface-builder","title":{"rendered":"Center Windows in Interface Builder"},"content":{"rendered":"<p>How many times have you been bitten by the problem of moving a window in Interface Builder, for easier editing, and then neglecting to put it back before saving it? Sometimes this can pop up as an embarrassing bug when you realize that your preferences have been saving an appropriate location for the window, but now new users are seeing it pop-up in the lower left corner of the window. <em>Where you left it the last time you edited it in Interface Builder!<\/em><\/p>\n<p>\nOne of the ingredients leading to this disaster is the relative difficulty of getting the window back to precisely where it belongs. Many times, a window is saved &#8220;centered&#8221; with the window autoposition springs set so that it will be centered on whatever screen the user has. But the tedium of getting it &#8220;back to center&#8221; can make you hesitant to move it to a more convenient position for editing. Worse, it can make it easy to &#8220;postpone&#8221; the act of putting it back where it belongs until you forget about it and ship that way.\n<\/p>\n<p>\nUnfortunately, the amazingly useful alignment and centering tools provided in Interface Builder only work on <em>view-level<\/em> interface elements. They don&#8217;t work on windows. Wouldn&#8217;t it be nice if you could easily and quickly snap a window back to a centered position?\n<\/p>\n<p>\nMy <a href=\"http:\/\/www.red-sweater.com\/AppleScript\/CenterWindow.zip\">Center Window<\/a> script lets you do just that. By adding this to the Interface Builder scripts menu, you can easily bounce a window back to horizontal center at any time by selecting the script from the Apple Script Menu, or (better!) by pressing a FastScripts keyboard shortcut. I&#8217;m using Cmd-Opt-C to center windows in the blink of an eye.\n<\/p>\n<p>\nNote: This script requires the <a href=\"http:\/\/www.seanet.com\/~jonpugh\/\">Jon&#8217;s Commands<\/a> scripting addition. If you don&#8217;t want to install that, you can modify the script to define the width and height of your main screen manually.\n<\/p>\n<p>\nIt should be pretty easy to modify the script to also position the Y-axis as you see fit.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>How many times have you been bitten by the problem of moving a window in Interface Builder, for easier editing, and then neglecting to put it back before saving it? Sometimes this can pop up as an embarrassing bug when you realize that your preferences have been saving an appropriate location for the window, but [&hellip;]<\/p>\n","protected":false},"author":10,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,5],"tags":[],"class_list":["post-65","post","type-post","status-publish","format-standard","hentry","category-usability","category-xcode"],"_links":{"self":[{"href":"https:\/\/redsweater.com\/blog\/wp-json\/wp\/v2\/posts\/65","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/redsweater.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/redsweater.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/redsweater.com\/blog\/wp-json\/wp\/v2\/users\/10"}],"replies":[{"embeddable":true,"href":"https:\/\/redsweater.com\/blog\/wp-json\/wp\/v2\/comments?post=65"}],"version-history":[{"count":0,"href":"https:\/\/redsweater.com\/blog\/wp-json\/wp\/v2\/posts\/65\/revisions"}],"wp:attachment":[{"href":"https:\/\/redsweater.com\/blog\/wp-json\/wp\/v2\/media?parent=65"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/redsweater.com\/blog\/wp-json\/wp\/v2\/categories?post=65"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/redsweater.com\/blog\/wp-json\/wp\/v2\/tags?post=65"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}