I’m using the Size Inspector for my document window’s XIB to create a Small 
Bottom Border as a Content Border.  From the top to the bottom of my window, 
not counting the title and tool bars, I got:

1. 20 pts. space w/ Autolayout
2. Text-editing (1 line) field, changing its size width-wise as the window does
3. 8 pts. space w/ Autolayout
4. WebView, changing its size as the window does
5. Formerly 0 pts. space, now 22 pts. space, both times with Autolayout

The 22 pts. of space added to the bottom exposes the Small Bottom Border.

I made a menu item to turn on/off the Status Bar.  I even put a check mark 
there as appropriate.  The problem is that the Bar doesn’t actually disappear, 
it just looks inactive.  If I try messing with the window’s frame NSRect, I 
shrink the WebView with the window but keep the Bar.  If I try messing with the 
WebView’s frame NSRect, the WebView just shifts down and leaves extra space on 
top.

Here’s my code:

//======
- (BOOL)validateUserInterfaceItem:(id<NSValidatedUserInterfaceItem>)anItem
{
    if ([anItem action] == @selector(hideShowStatusBar:)) {
        // The "Status Bar" menu item is checked on/off based on the actual 
Status Bar being non-zero in height.
        [(id)anItem setState:([[self.windowControllers.firstObject window] 
contentBorderThicknessForEdge:NSMinYEdge] ? NSOnState : NSOffState)];
    }
    return [super validateUserInterfaceItem:anItem];
}

- (IBAction)hideShowStatusBar:(id)sender
{
    NSWindow * const  window = self.windowForSheet;
    //NSRect       windowFrame = window.frame;
    NSRect      webViewFrame = self.webView.frame;

    if ([window contentBorderThicknessForEdge:NSMinYEdge]) {
        [window setContentBorderThickness:0.0 forEdge:NSMinYEdge];

        //windowFrame.origin.y += PrStatusBarHeight;
        //windowFrame.size.height -= PrStatusBarHeight;
        
        webViewFrame.origin.y -= PrStatusBarHeight;
        //webViewFrame.size.height += PrStatusBarHeight;  // Never has an 
effect.
    } else {
        // Increase the window's size to reveal the Status Bar.
        [window setContentBorderThickness:PrStatusBarHeight forEdge:NSMinYEdge];

        //windowFrame.origin.y -= PrStatusBarHeight;
        //windowFrame.size.height += PrStatusBarHeight;
        
        webViewFrame.origin.y += PrStatusBarHeight;
        //webViewFrame.size.height -= PrStatusBarHeight;  // Never has an 
effect.
    }
    //[window setAutorecalculatesContentBorderThickness:NO forEdge:NSMinYEdge];
    //[window setFrame:windowFrame display:YES animate:YES];
    self.webView.frame = webViewFrame;
}
//======

— 
Daryle Walker
Mac, Internet, and Video Game Junkie
darylew AT mac DOT com 

_______________________________________________

Cocoa-dev mailing list ([email protected])

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to