Skip to content

Conversation

httnn
Copy link

@httnn httnn commented Sep 16, 2025

this wasn't previously implemented apparently because VoiceOver doesn't support it directly. however, there are other tools (like the Accessibility Inspector) that are able to set values so i think it's useful for at least building UI automations.

tested manually and confirmed to work!

fixes #612

@DataTriny
Copy link
Member

Thanks @httnn, this looks like a good start. You're absolutely right, we should try to not solely focus on what VoiceOver needs.

However I don't think this method is only used to set text value. Have you had a look at how Chromium handles it? If not, this might help you start browsing the code.

@httnn
Copy link
Author

httnn commented Sep 17, 2025

i though i saw somewhere in the Apple documentation that this method would only accept NSString, but i can't find it anymore. must have hallucinated it! the method indeed accepts any type of value. from what i've gathered, the method is only called with text and numbers in reality, so maybe i should just make it accept an NSObject again and add support for numbers too?

@DataTriny
Copy link
Member

from what i've gathered, the method is only called with text and numbers in reality

This was my conclusion too.

maybe i should just make it accept an NSObject again and add support for numbers too?

This would be appreciated, if you don't mind.

@httnn
Copy link
Author

httnn commented Sep 17, 2025

this should do it. required temporarily backporting downcast_ref from objc2 0.6: https://docs.rs/objc2/latest/objc2/runtime/struct.AnyObject.html#method.downcast_ref but other than that pretty straightforward.

Copy link
Member

@DataTriny DataTriny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Were you able to test setting a numeric value on a slider for instance.

The backporting is indeed annoying, I hope we can get rid of it soon.

@DataTriny DataTriny changed the title implement setting values on macOS fix: Implement setting values on macOS Sep 30, 2025
@httnn
Copy link
Author

httnn commented Oct 6, 2025

Were you able to test setting a numeric value on a slider for instance.

yes. using the Accessibility Inspector, when the node has a numeric value, setAccessibilityValue is called with an NSNumber, and with NSString otherwise.

@DataTriny
Copy link
Member

Thanks @httnn,

CI is reporting formatting issues. Please run cargo fmt and make sure to address any warnings you might get by running cargo clippy.

After that it will be good to merge.

@httnn
Copy link
Author

httnn commented Oct 8, 2025

should be formatted now!

@mwcampbell
Copy link
Contributor

@httnn Thank you for this contribution. In is_selector_allowed, can you please change the logic for setAccessibilityValue: to allow either the old condition or your new one? That way, if a text input implementation doesn't actually support the SetValue action, we still get the expected behavior out of VoiceOver. Thanks again.

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

Successfully merging this pull request may close these issues.

setAccessibilityValue on macOS
3 participants