You're playing around with NSWindow, and you find this function called setFrame, setFrameOrigin, and setFrameTopLeftPoint. You feel like you are the king of the world when the thought of being able to move your window anywhere programmatically consume you. Except that when you realized that Cocoa stops you from doing that.
Cocoa allows you to move the window anywhere using those functions, except when your window starts going above the menu bar.
For instance, consider the following scenario:
When you call window.setFrameTopLeftPoint with the position of (x: 100, y: 800) your window's top left will actually be positioned at (x: 100, y: 778), right under the menu bar.
Same goes with the other setFrame* variants, your window will be pushed down until no part of your window is above the menu bar.
This is of course unless your window is the size (or bigger) than the screen, in which case it has no choice.
Cocoa allows you to move the window anywhere using those functions, except when your window starts going above the menu bar.
For instance, consider the following scenario:
- Screen Configuration:
- Resolution at 1280 x 800
- Menu bar height = 22 pixel
- Which means, the menu bar starts at y = 778 (Cocoa coordinate start at the bottom left)
- Your Window:
- Size is 100 x 100
When you call window.setFrameTopLeftPoint with the position of (x: 100, y: 800) your window's top left will actually be positioned at (x: 100, y: 778), right under the menu bar.
Same goes with the other setFrame* variants, your window will be pushed down until no part of your window is above the menu bar.
This is of course unless your window is the size (or bigger) than the screen, in which case it has no choice.