Window resizable - kAXGrowAreaAttribute always ret

2019-08-05 04:27发布

In my app I want to check if windows from others apps are resizable.

I´m using the accessibility API to test if the window has the kAXGrowAreaAttribute attribute (if NULL is not resizable) as Peter Hosey answered in this question.

The problem is that the kAXGrowAreaAttribute returned value is always NULL it doesn´t matter if the window is resizable or not. Note: to retrieve the value I´m using the UIElementUtilities class from the Apple UIElementInspector example (I also have tried using AXUIElementCopyAttributeValue directly with the same result).

Any idea? I´m working in Lion, could be this the problem? Thanks in advance.

EDITED:

Playing around with the UIElementUtilities class methods I found a solution.

Just use the method

+ (BOOL)canSetAttribute:(NSString *)attributeName ofUIElement:(AXUIElementRef)element

with the kAXSizeAttribute and the focused window. It returns YES or NO depending if the window is sizable or not...

1条回答
家丑人穷心不美
2楼-- · 2019-08-05 05:08

It probably is because you're in Lion. The size box was killed off; resizable windows are resizable at every edge now.

And yes, testing whether the size can be changed is probably the right way. It seems to work for me in Snow Leopard.

查看更多
登录 后发表回答