Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parameterized attributes do not work! #44

Open
AlbatorLaho opened this issue Dec 21, 2024 · 0 comments
Open

Parameterized attributes do not work! #44

AlbatorLaho opened this issue Dec 21, 2024 · 0 comments

Comments

@AlbatorLaho
Copy link

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant