Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Minimum window size of a Mac OS X application

Two questions here.

First question, In my Mac OS X application the window has resizing enabled. My window contents are on a 500x500 window size. Problem is that user can resize it so some of the contents cutts off. What I need to do so user can only resize to a minimum size (In my case 500x500)?

Second question, When I close my Mac application (by clicking red cross button on window top) the app icon stays in the dock at the bottom. When user click on it again it does not fire up the application unless user quit the application all togeter and relaunches it again. What settings do I need so user can close and relaunch it by clicking dock icon?

Thanks

like image 566
Leo Avatar asked Mar 31 '11 08:03

Leo


People also ask

How do I manage window size on Mac?

Move your cursor to any side of a window—top, bottom, left, or right. As the cursor nears the edge of the window, it changes to a double-ended arrow. When you see the double-ended arrow, click and drag to resize the window. Resizing also works on the corners of a window.

How do you change the size a window opens on Mac?

All replies. Open the window by double-clicking on the Desktop disk icon. Change the window size to what you want and reposition the window where you want it locate.


1 Answers

Use -[NSWindow setMinSize:] to set the minimum size programmatically, but you can also set the minimum size inside Interface Builder (look at the tab with the sizes).

To make the application quit when the window is closed, you need to add this to your app delegate:

- (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)theApplication
{
    return YES;
}
like image 129
DarkDust Avatar answered Oct 15 '22 11:10

DarkDust