Skip to content

8379347: VoiceOver Doesn't Correctly Identify JToggleButtons as "toggle buttons"#30096

Closed
mickleness wants to merge 4 commits intoopenjdk:masterfrom
mickleness:JDK-8379347
Closed

8379347: VoiceOver Doesn't Correctly Identify JToggleButtons as "toggle buttons"#30096
mickleness wants to merge 4 commits intoopenjdk:masterfrom
mickleness:JDK-8379347

Conversation

@mickleness
Copy link
Copy Markdown
Contributor

@mickleness mickleness commented Mar 5, 2026

With this PR: VoiceOver correctly identifies a JToggleButton as a "toggle button" (instead of a "checkbox")

This adds the subrole of NSAccessibilityToggleSubrole (which Accessibility Inspector shows as the subrole "AXToggle").

In the screenshot the subrole appears as expected, and the "class" (in the "element") section is different from production:

toggled button fixed

Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8379347: VoiceOver Doesn't Correctly Identify JToggleButtons as "toggle buttons" (Bug - P4)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/30096/head:pull/30096
$ git checkout pull/30096

Update a local copy of the PR:
$ git checkout pull/30096
$ git pull https://git.openjdk.org/jdk.git pull/30096/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 30096

View PR using the GUI difftool:
$ git pr show -t 30096

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/30096.diff

Using Webrev

Link to Webrev Comment

If a button uses Swing's AccessibleRole.TOGGLE_BUTTON, then as far as Apple's UI is concerned: it should have a role of NSAccessibilityCheckBoxRole and a subrole of NSAccessibilityToggleSubrole
@bridgekeeper
Copy link
Copy Markdown

bridgekeeper Bot commented Mar 5, 2026

👋 Welcome back jwood! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link
Copy Markdown

openjdk Bot commented Mar 5, 2026

@mickleness This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8379347: VoiceOver Doesn't Correctly Identify JToggleButtons as "toggle buttons"

Reviewed-by: honkar, kizune, prr

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 335 new commits pushed to the master branch:

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@prrace, @honkar-jdk, @azuev-java) but any other Committer may sponsor as well.

➡️ To flag this PR as ready for integration with the above commit message, type /integrate in a new comment. (Afterwards, your sponsor types /sponsor in a new comment to perform the integration).

@openjdk openjdk Bot added the client client-libs-dev@openjdk.org label Mar 5, 2026
@openjdk
Copy link
Copy Markdown

openjdk Bot commented Mar 5, 2026

@mickleness The following label will be automatically applied to this pull request:

  • client

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@mickleness mickleness changed the title VoiceOver Doesn't Correctly Identify JToggleButtons as "toggle buttons" 8379347: VoiceOver Doesn't Correctly Identify JToggleButtons as "toggle buttons" Mar 6, 2026
@openjdk openjdk Bot added the rfr Pull request is ready for review label Mar 6, 2026
@mlbridge
Copy link
Copy Markdown

mlbridge Bot commented Mar 6, 2026

Webrevs

@prrace
Copy link
Copy Markdown
Contributor

prrace commented Mar 26, 2026

@azuev-java please review
Also @honkar-jdk please review

@openjdk openjdk Bot added the ready Pull request is ready to be integrated label Mar 26, 2026
Copy link
Copy Markdown
Contributor

@honkar-jdk honkar-jdk left a comment

Choose a reason for hiding this comment

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

VO announces first part correctly and then it says "To select or deselect the checkbox press Ctrl+Option+Space" Shouldn't it say toggleButton here?

return NSAccessibilityCheckBoxRole;
}

- (NSAccessibilitySubrole _Nullable)accessibilitySubrole
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Since this is JToggleButton, do we need to add this subrole to ButtonAccessbility.m ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure I understand your question.

Currently if any java.awt.Component has the role AccessibleRole.TOGGLE_BUTTON: then (based on the new proposed changes to CommonComponentAccessibility) that java.awt.Component is mapped to a CheckboxAccessibility object.

By contrast: if a java.awt.Component uses AccessibleRole.PUSH_BUTTON, then it is mapped to a ButtonAccessibility object.

... so as I understand it: assuming roles are immutable, we'll never use ButtonAccessibility.m for toggle buttons. So I don't think ButtonAccessibility.m will benefit from the subrole getter here. (We could add it someday for other subroles, like NSAccessibilityToolbarButtonSubrole, but that's outside the scope of this ticket.)

Does that speak to your question, or did I misunderstand what you're asking?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Let me re-phrase for clarity:

Initially I thought for JToggleButton, AccessibleRole => Button and AccessibleSubRole => toggleButton made more logical sense.

I made slight modification as below -
[rolesMap setObject:@"ButtonAccessibility" forKey:@"togglebutton"];
and moved the above code snippet to ButtonAccessbility.m.

With this change the VO announces that it is JToggleButton and to select/deselect button press Ctrl + Option + Space which seemed correct.

Revisited the code and I believe "checkbox" Role is more appropriate for JToggleButton for another reason as well - accessibilityValue for NSAccessibilityButtonRole is NULL which may not be the correct return value for JToggleButton.

In short, your changes look good. Thanks for the details.

Comment on lines +40 to +47
String INSTRUCTIONS = "INSTRUCTIONS (Mac-only):\n" +
"1. Open VoiceOver\n" +
"2. Move the VoiceOver cursor over the JToggleButton.\n" +
"3. Observe how VoiceOver identifies the toggle button.\n\n" +
"Expected behavior: VoiceOver should identify it as a " +
"\"toggle button\". It should not say \"checkbox\".\n\n" +
"If you select the link using \"Accessibility " +
"Inspector\": it should identify its subrole as AXToggle.";
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You could use text blocks here

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

OK, this is updated

@mickleness
Copy link
Copy Markdown
Contributor Author

VO announces first part correctly and then it says "To select or deselect the checkbox press Ctrl+Option+Space" Shouldn't it say toggleButton here?

Good question, but I think this is the standard behavior.

Here is an example of a toggle button in Font Book, which presumably is working according to Apple's standards/expectations. Here VO also says "to select or deselect this checkbox":

toggle.button.demo.mp4

@openjdk openjdk Bot removed the ready Pull request is ready to be integrated label Mar 27, 2026
Copy link
Copy Markdown
Member

@azuev-java azuev-java left a comment

Choose a reason for hiding this comment

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

Looks good.

@openjdk openjdk Bot added the ready Pull request is ready to be integrated label Mar 27, 2026
Copy link
Copy Markdown
Contributor

@honkar-jdk honkar-jdk left a comment

Choose a reason for hiding this comment

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

Changes LGTM

return NSAccessibilityCheckBoxRole;
}

- (NSAccessibilitySubrole _Nullable)accessibilitySubrole
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Let me re-phrase for clarity:

Initially I thought for JToggleButton, AccessibleRole => Button and AccessibleSubRole => toggleButton made more logical sense.

I made slight modification as below -
[rolesMap setObject:@"ButtonAccessibility" forKey:@"togglebutton"];
and moved the above code snippet to ButtonAccessbility.m.

With this change the VO announces that it is JToggleButton and to select/deselect button press Ctrl + Option + Space which seemed correct.

Revisited the code and I believe "checkbox" Role is more appropriate for JToggleButton for another reason as well - accessibilityValue for NSAccessibilityButtonRole is NULL which may not be the correct return value for JToggleButton.

In short, your changes look good. Thanks for the details.

@honkar-jdk
Copy link
Copy Markdown
Contributor

VO announces first part correctly and then it says "To select or deselect the checkbox press Ctrl+Option+Space" Shouldn't it say toggleButton here?

Good question, but I think this is the standard behavior.

Here is an example of a toggle button in Font Book, which presumably is working according to Apple's standards/expectations. Here VO also says "to select or deselect this checkbox":

Sounds reasonable. Good to match it with native app behavior.

@mickleness
Copy link
Copy Markdown
Contributor Author

/integrate

@openjdk openjdk Bot added the sponsor Pull request is ready to be sponsored label Mar 28, 2026
@openjdk
Copy link
Copy Markdown

openjdk Bot commented Mar 28, 2026

@mickleness
Your change (at version adc8c75) is now ready to be sponsored by a Committer.

@azuev-java
Copy link
Copy Markdown
Member

/sponsor

@openjdk
Copy link
Copy Markdown

openjdk Bot commented Mar 28, 2026

Going to push as commit ac24255.
Since your change was applied there have been 335 commits pushed to the master branch:

Your commit was automatically rebased without conflicts.

@openjdk openjdk Bot added the integrated Pull request has been integrated label Mar 28, 2026
@openjdk openjdk Bot closed this Mar 28, 2026
@openjdk openjdk Bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Mar 28, 2026
@openjdk openjdk Bot removed the sponsor Pull request is ready to be sponsored label Mar 28, 2026
@openjdk
Copy link
Copy Markdown

openjdk Bot commented Mar 28, 2026

@azuev-java @mickleness Pushed as commit ac24255.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

client client-libs-dev@openjdk.org integrated Pull request has been integrated

Development

Successfully merging this pull request may close these issues.

4 participants