Eugene Gordin
Eugene Gordin

Reputation: 4107

How to group several windows together and place them into particular location on the screen?

I have 5 different windows in my app that are on the screen simultaneously. It really bothers me sometimes that they are spread out on the screen after I use the app for a while. So I want to make an action that would locate all these windows into particular positions on the screen at any time this action is called.

Does anyone know how to group these windows together and "memorize" the particular positions for them?!

BEFORE the action

enter image description here

AFTER the action been applied

enter image description here

Upvotes: 0

Views: 118

Answers (1)

Michael Dautermann
Michael Dautermann

Reputation: 89509

IIRC, Xcode (3.X) used to have this feature that would allow users to tile windows on top of each other in roughly the same way.

In any event, NSApplication has a windows API (or orderedWindows) that allows you to get an array of all your application's windows. You can walk this array of windows and based on the screen size (which you should be able to get via NSScreen API's including frame, which gives the actual screen size), you can implement a tile windows function for your own windows.

The sexiest "tile" function would animate moving the windows, which you may be able to do via NSWindow's [setFrame: display: animate:] method.

Upvotes: 1

Related Questions