Is there any way I can detect if windows from my application are overlapping ?
Asked
Active
Viewed 299 times
0
-
1Check if http://stackoverflow.com/questions/11473189/multiple-uiviews-overlapping helps you. – ott-- Nov 11 '12 at 20:17
1 Answers
2
use the windows in NSApp
//find overlaps
for (NSWindow *w in [NSApp windows]) {
for (NSWindow *w2 in [NSApp windows]) {
if (CGRectIntersectsRect(w.frame, w2.frame) || CGRectIntersectsRect(w2.frame, w.frame)) {
// add the pairs w & w2 up in a NSDictionary with w as key and an array of w2s it intersects
// ....
}
}
}
//handle all the queued overlaps....
-
Great, thanks ! Is there also a way to get a notification or something when one window intersect another? Maybe rectDidIntersect or something, so it won't have to poll it all the time ? – cocoa coder Nov 12 '12 at 22:17
-
1well, there are notifications sent when they move or resize. you could sign up for those and then look at the windows when a notification comes in – Daij-Djan Nov 13 '12 at 07:32