I've encountered some problems with parameterized attributes. (running MacOS 12, Monterey)
The Attribute enum for parameterized values are incorrect... they shouldn't end with Parameterized.
enum Attribute {
case boundsForRangeParameterized = "AXBoundsForRangeParameterized"
// should be:
case boundsForRangeParameterized = "AXBoundsForRange"
}
Personally, I would also like the parameterized attributes to be separated into another enum.
I'm not sure why they're in the same enum in the first place... they're never interchangeable are they?
I realize it's probably for simplicity of functions like attributeIsSupported... but I'd still think it makes sense for them to be separated.
The other thing I found is that the parameterizedAttribute in UIElement doesn't work correctly.
I was trying to set AXBoundsForRange and passing in a CFRange, but it would throw an AXError.IllegalArgument error.
I figured out that it's because the param value does not use packAXValue, unlike setAttribute.
open func parameterizedAttribute<T, U>(_ attribute: String, param: U) throws -> T? {
...
let error = AXUIElementCopyParameterizedAttributeValue(
element, attribute as CFString, param as AnyObject, &value
)
// should be something like this:
let error = AXUIElementCopyParameterizedAttributeValue(
element, attribute as CFString, packAXValue(param), &value
)
...
}
I can't easily test this fully, since I can't access packAXValue in an extension (because it's fileprivate), but doing manual conversion to an AXValue seems to fix it!
I've encountered some problems with parameterized attributes. (running MacOS 12, Monterey)
The
Attributeenum for parameterized values are incorrect... they shouldn't end withParameterized.Personally, I would also like the parameterized attributes to be separated into another enum.
I'm not sure why they're in the same enum in the first place... they're never interchangeable are they?I realize it's probably for simplicity of functions like
attributeIsSupported... but I'd still think it makes sense for them to be separated.The other thing I found is that the
parameterizedAttributeinUIElementdoesn't work correctly.I was trying to set
AXBoundsForRangeand passing in aCFRange, but it would throw anAXError.IllegalArgumenterror.I figured out that it's because the
paramvalue does not usepackAXValue, unlikesetAttribute.I can't easily test this fully, since I can't access
packAXValuein an extension (because it'sfileprivate), but doing manual conversion to anAXValueseems to fix it!