开发者

How to snap an NSWindow to a grid

How can I snap an NSWindow to a grid? Any good algorithms, tutorials that are rec开发者_C百科ommended?


If you just want to monitor you app's windows its easy to just monitor the own windows locations and "override" their locations as soon as they come to a grid boundary. You might want to checkout the KVO documentation for observing NSWindow properties.

What I think you actually want to do is monitor ALL windows, including those from other apps. If so, have a look at Apples Accessibility APIs.

Keep in mind when you use AX APIs you have to either enable accessibility support in the system preferences or authorize your app!

Update:


Example: http://toxicsoftware.com/snappingwindow_cocoa_source_code/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜