{"id":48,"date":"2008-05-25T23:10:25","date_gmt":"2008-05-26T04:10:25","guid":{"rendered":"http:\/\/vgable.com\/blog\/2008\/05\/25\/objects-that-wont-hide\/"},"modified":"2008-05-26T14:04:26","modified_gmt":"2008-05-26T19:04:26","slug":"objects-that-wont-hide","status":"publish","type":"post","link":"https:\/\/vgable.com\/blog\/2008\/05\/25\/objects-that-wont-hide\/","title":{"rendered":"Objects that Won&#8217;t Hide"},"content":{"rendered":"<p><em>NOTE: Although this specific <a href=\"http:\/\/vgable.com\/blog\/category\/bug-bite\/\">Bug Bite<\/a> is about <code>NSTextView<\/code>, and the &#8220;hidden&#8221; property, the same underlying issue applies to other interface-objects (<code>NSTableView<\/code>, etc.), and different properties, like size.<\/em><\/p>\n<p><strong>Problem<\/strong><\/p>\n<p>If you send a <code>setHidden:YES<\/code> message to an <code>NSTextView<\/code>, and it&#8217;s text disappears, but the view itself (white box) stays visible here&#8217;s the problem, and the solution.<\/p>\n<p>It turns out that if you created the <code>NSTextView<\/code> by dragging it off the pallet in Interface Builder, then it&#8217;s not an <code>NSTextView<\/code>.  It&#8217;s an <code>NSTextView<\/code> wrapped inside an <code>NSClipView<\/code> inside an <code>NSScrollView<\/code>.  The <code>NSScrollView<\/code> is what puts up the scroll-bars if the <code>NSTextView<\/code> gets really big; the <code>NSClipView<\/code> helps make the scrolling work.<\/p>\n<p>So if <code>text<\/code> is your <code>IBOutlet<\/code> to your <code>NSTextView<\/code>, then when you say <code>[text setHidden:YES];<\/code>, the <code>NSTextView<\/code> <b>is<\/b> hidden, but the the total package won&#8217;t disappear, unless you hide the <code>NSScrollView<\/code> as well.<\/p>\n<p><strong>Solutions<\/strong><\/p>\n<p>You can send the message to <code>NSScrollView<\/code> containing <code>text<\/code>, like so:<br \/>\n&nbsp;&nbsp;&nbsp;<code>[[text enclosingScrollView] setHidden:YES];<\/code>.<br \/>\nThis will hide everything inside the <code>NSScrollView<\/code>, including <code>text<\/code>.<\/p>\n<p>Another solution is to create <em>just<\/em> an <code>NSTextView<\/code> in Interface Builder.  To do this, put an <code>NSView<\/code> in your interface (it&#8217;s called a &#8220;Custom View&#8221;,in the Interface Builder objects pallet).  Then select it, bring up the object inspector (cmd-shift-i), choose the &#8220;custom class&#8221; from the category menu at the top, and select <code>NSTextView<\/code> from the list of subclasses.  This puts an <code>NSTextView<\/code> in your interface, without the surrounding clip and scroll views.  Unfortunately, it also means you can&#8217;t configure it in Interface Builder, beyond resizing it.  That&#8217;s why I&#8217;m not partial to this approach, although I have used it.<\/p>\n<p>Thanks to <a href=\"http:\/\/mirasoftware.com\/\">ZachR<\/a> for suggesting <code>enclosingScrollView<\/code>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>NOTE: Although this specific Bug Bite is about NSTextView, and the &#8220;hidden&#8221; property, the same underlying issue applies to other interface-objects (NSTableView, etc.), and different properties, like size. Problem If you send a setHidden:YES message to an NSTextView, and it&#8217;s text disappears, but the view itself (white box) stays visible here&#8217;s the problem, and the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18,6,38,3,5,4],"tags":[614],"class_list":["post-48","post","type-post","status-publish","format-standard","hentry","category-bug-bite","category-cocoa","category-interface-builder","category-macosx","category-objective-c","category-programming","tag-interface-builder"],"_links":{"self":[{"href":"https:\/\/vgable.com\/blog\/wp-json\/wp\/v2\/posts\/48","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/vgable.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/vgable.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/vgable.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/vgable.com\/blog\/wp-json\/wp\/v2\/comments?post=48"}],"version-history":[{"count":0,"href":"https:\/\/vgable.com\/blog\/wp-json\/wp\/v2\/posts\/48\/revisions"}],"wp:attachment":[{"href":"https:\/\/vgable.com\/blog\/wp-json\/wp\/v2\/media?parent=48"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/vgable.com\/blog\/wp-json\/wp\/v2\/categories?post=48"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/vgable.com\/blog\/wp-json\/wp\/v2\/tags?post=48"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}