views:

78

answers:

3

I am writting an application which must know when a window is resized or moved. I had a look on notifications but it seems it does not do what I expected.

Do you have any idea how I can achieve this?

A: 

Give your window a delegate. The NSWindowDelegate protocol has windowWillResize:toSize: and windowWillMove: methods.

Carl Norum
Does it work for all windows? I mean not only the one from the application?
AP
+2  A: 

Given your response to Carl's answer, I'd suggest the Accessibility API, which can give you access (and I believe frame change notifications) for all windows, not just your app's.

Joshua Nozzi
It's a good idea unfortunatly, notifications are raised when thing are done and not during moving or resizing :(
AP
It is unfortunately the best you can do for other applications' windows.
Joshua Nozzi
A: 

If you want window size/ordering then take a look at CGWindow.h. CGWindowListCreateDescriptionFromArray() is probably what you want.

NSWindowList() is also useful for a list of windows.

Leibowitzn